Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
base repository: angular-ui/ui-grid
Choose a Base Repository
angular-ui/ui-grid
Aardvark71/ng-grid
AdelinGhanaem/ng-grid
AlasdairSwan/ng-grid
AntonFend/ng-grid
CNXTEoEorg/ui-grid
Dashue/ng-grid
Donderda/ng-grid
EricEngineered/ng-grid
EugeneBorshch/ng-grid
EugeneTruly/ng-grid
GenesysPureConnect/ng-grid
Jammasternam/ng-grid
JavaBasketball/ui-grid
Jenk-Rendar/ng-grid
JonahKE/ui-grid
KNaved/ui-grid
Klarence/ng-grid
Martin17/ng-grid
Mistobaan/ng-grid
Moreface/ng-grid
Pasha-Pramati/ng-grid
Premier/ng-grid
Reskov/ng-grid
SummerDejavu/ng-grid
UrvilKaswala/ng-grid
Wiinis/ng-grid
YonatanKra/ui-grid
a5sk4s/ng-grid
aaks2010/ng-grid
akhileshappala/ui-grid
alecswan/ng-grid
alexspurling/ng-grid
alpinegizmo/ng-grid
anuradha18/ng-grid
archsh/ng-grid
ata-n/ng-grid
avgalon/ng-grid
avikaco/ng-grid
ballmw/ng-grid
bbradbury/ng-grid
benjaminkitt/ng-grid
benmj/ng-grid
blackneus/ng-grid
bmleite/ng-grid
boland/ng-grid
bpoussin/ng-grid
bradlund/ng-grid
bundance/ng-grid
caphun/ng-grid
ccreed2/ui-grid
cdesogeti/ng-grid
ceolter/ui-grid
chanu587/ng-grid
chinnurtb/ng-grid
chiragchamoli/ng-grid
choroshin/ng-grid
christoffee/ng-grid
clkao/ng-grid
cxl55/ng-grid
daclubb/ng-grid
darkhorse-dev/ui-grid
darknos/ng-grid
dcolens/ng-grid
dean-me/ng-grid
demon-lord/ng-grid
devony/ng-grid
doctorsender/ng-grid
ebraminio/ng-grid
ezecafre89/ng-grid
felixhummel/ng-grid
firmusoft/ng-grid
francescoagati/ng-grid
frogomatic/ng-grid
garaboncias/ng-grid
getuliojr/ng-grid
giosakti/ng-grid
goldhand/ng-grid
goodluck2016/ui-grid
hawtio/ng-grid
hey24sheep/ui-grid
hoshidaniel/ng-grid
hotings/ng-grid
hucarrot/ng-grid
imloama/ng-grid
ineedfat/ng-grid
is-fredrik/ng-grid
ismakv/ui-grid
itxd/ui-grid
jeado/ng-grid
jeanpuga/ui-grid
jeffbcross/ng-grid
jeffslofish/ng-grid
jessegavin/ng-grid
jfzman/ng-grid
jharohit/ng-grid
jiacomino/ng-grid
jimhotchkin-wf/ng-grid
jimmytheneutrino/ng-grid
jmaynier/ng-grid
johlrich/ng-grid
johnobe/ng-grid
johnparn/ng-grid
jon23cooper/ng-grid
jozzhart/ng-grid
jspeshu/ng-grid
jstrachan/ng-grid
juliofreitas/ui-grid
jurby/ng-grid
karnyj/ng-grid
keathley/ng-grid
keithharvey/ng-grid
kmussel/ng-grid
koen-serry/ng-grid
konrad-garus/ng-grid
krahman/ng-grid
ksmoore/ng-grid
kugel-soft/ui-grid
lebedevsergey/ui-grid-fix-issue-with-pinned-columns-in-v2
leninloganathan/ui-grid
liergouzi/ui-grid
loiphamvn/ng-grid
longFeiLi/ui-grid
marciosartini/ng-grid
marklagendijk/ng-grid
martijnve/ng-grid
mathiasdose/ng-grid
mathieurivest/ng-grid
matpaprocki/ng-grid
mattlaver/ng-grid
maxcan/ng-grid
mchapman/ng-grid
mediaprojects/ng-grid
mgibson/ng-grid
mheye/ng-grid
mmatczak/ui-grid
mschroering/ng-grid
musically-ut/ng-grid
mxreppy/ng-grid
niilante/ui-grid
nishant8BITS/ng-grid
noming/ng-grid
nuclearghost/ng-grid
orneryd/ng-grid
owenXin/ng-grid
pdegenhardt/ng-grid
pdemanget/ng-grid
ppollono/ng-grid
prabhat2233/ui-grid
presidento/ng-grid
r7lemieux/ng-grid
richiepreece/ng-grid
ronbuchanan/ng-grid
sagarwasule/ng-grid
sapronlee/ng-grid
satyanand/ng-grid
sax1johno/ui-grid
seankenny/ng-grid
simonengelhardt/ng-grid
simplyjames/ng-grid
skusunam/ng-grid
snapappointments/ui-grid
sofibraun/ng-grid
solvebio/ng-grid
songguang-2010/ng-grid
sonicparke/ng-grid
sourcec0de/ng-grid
sravanthipoujula/ng-grid
sskyy/ng-grid
stan-z/ng-grid
strider820/ng-grid
sunfirefox/ng-grid
surfer26th/ng-grid
suryasingh/ng-grid
swalters/ng-grid
tcrimi/ng-grid
tetralon/ng-grid
thedarkjester/ng-grid
tjosbon/ng-grid
tkhemani/ng-grid
tradingscreen/ng-grid
tuckerjt07/ui-grid
turn/ng-grid
uapui-dev/ng-grid
vargose/ng-grid
vladovidiu/ng-grid
wdmny/ng-grid
wp-ng/ui-grid
xordad/ng-grid
xtidt/ui-grid
xtreme-christophe/ng-grid
yangsong158/ui-grid
yanl/ng-grid
yarl/ng-grid
yesnault/ng-grid
yunmanger1/ng-grid
zelingo/ui-grid
zhangdiwaa/ng-grid
zhanghaihua/ng-grid
ztp130213/ng-grid
Nothing to show
base: cf70e90624b1
head repository: angular-ui/ui-grid
Choose a Head Repository
angular-ui/ui-grid
Aardvark71/ng-grid
AdelinGhanaem/ng-grid
AlasdairSwan/ng-grid
AntonFend/ng-grid
CNXTEoEorg/ui-grid
Dashue/ng-grid
Donderda/ng-grid
EricEngineered/ng-grid
EugeneBorshch/ng-grid
EugeneTruly/ng-grid
GenesysPureConnect/ng-grid
Jammasternam/ng-grid
JavaBasketball/ui-grid
Jenk-Rendar/ng-grid
JonahKE/ui-grid
KNaved/ui-grid
Klarence/ng-grid
Martin17/ng-grid
Mistobaan/ng-grid
Moreface/ng-grid
Pasha-Pramati/ng-grid
Premier/ng-grid
Reskov/ng-grid
SummerDejavu/ng-grid
UrvilKaswala/ng-grid
Wiinis/ng-grid
YonatanKra/ui-grid
a5sk4s/ng-grid
aaks2010/ng-grid
akhileshappala/ui-grid
alecswan/ng-grid
alexspurling/ng-grid
alpinegizmo/ng-grid
anuradha18/ng-grid
archsh/ng-grid
ata-n/ng-grid
avgalon/ng-grid
avikaco/ng-grid
ballmw/ng-grid
bbradbury/ng-grid
benjaminkitt/ng-grid
benmj/ng-grid
blackneus/ng-grid
bmleite/ng-grid
boland/ng-grid
bpoussin/ng-grid
bradlund/ng-grid
bundance/ng-grid
caphun/ng-grid
ccreed2/ui-grid
cdesogeti/ng-grid
ceolter/ui-grid
chanu587/ng-grid
chinnurtb/ng-grid
chiragchamoli/ng-grid
choroshin/ng-grid
christoffee/ng-grid
clkao/ng-grid
cxl55/ng-grid
daclubb/ng-grid
darkhorse-dev/ui-grid
darknos/ng-grid
dcolens/ng-grid
dean-me/ng-grid
demon-lord/ng-grid
devony/ng-grid
doctorsender/ng-grid
ebraminio/ng-grid
ezecafre89/ng-grid
felixhummel/ng-grid
firmusoft/ng-grid
francescoagati/ng-grid
frogomatic/ng-grid
garaboncias/ng-grid
getuliojr/ng-grid
giosakti/ng-grid
goldhand/ng-grid
goodluck2016/ui-grid
hawtio/ng-grid
hey24sheep/ui-grid
hoshidaniel/ng-grid
hotings/ng-grid
hucarrot/ng-grid
imloama/ng-grid
ineedfat/ng-grid
is-fredrik/ng-grid
ismakv/ui-grid
itxd/ui-grid
jeado/ng-grid
jeanpuga/ui-grid
jeffbcross/ng-grid
jeffslofish/ng-grid
jessegavin/ng-grid
jfzman/ng-grid
jharohit/ng-grid
jiacomino/ng-grid
jimhotchkin-wf/ng-grid
jimmytheneutrino/ng-grid
jmaynier/ng-grid
johlrich/ng-grid
johnobe/ng-grid
johnparn/ng-grid
jon23cooper/ng-grid
jozzhart/ng-grid
jspeshu/ng-grid
jstrachan/ng-grid
juliofreitas/ui-grid
jurby/ng-grid
karnyj/ng-grid
keathley/ng-grid
keithharvey/ng-grid
kmussel/ng-grid
koen-serry/ng-grid
konrad-garus/ng-grid
krahman/ng-grid
ksmoore/ng-grid
kugel-soft/ui-grid
lebedevsergey/ui-grid-fix-issue-with-pinned-columns-in-v2
leninloganathan/ui-grid
liergouzi/ui-grid
loiphamvn/ng-grid
longFeiLi/ui-grid
marciosartini/ng-grid
marklagendijk/ng-grid
martijnve/ng-grid
mathiasdose/ng-grid
mathieurivest/ng-grid
matpaprocki/ng-grid
mattlaver/ng-grid
maxcan/ng-grid
mchapman/ng-grid
mediaprojects/ng-grid
mgibson/ng-grid
mheye/ng-grid
mmatczak/ui-grid
mschroering/ng-grid
musically-ut/ng-grid
mxreppy/ng-grid
niilante/ui-grid
nishant8BITS/ng-grid
noming/ng-grid
nuclearghost/ng-grid
orneryd/ng-grid
owenXin/ng-grid
pdegenhardt/ng-grid
pdemanget/ng-grid
ppollono/ng-grid
prabhat2233/ui-grid
presidento/ng-grid
r7lemieux/ng-grid
richiepreece/ng-grid
ronbuchanan/ng-grid
sagarwasule/ng-grid
sapronlee/ng-grid
satyanand/ng-grid
sax1johno/ui-grid
seankenny/ng-grid
simonengelhardt/ng-grid
simplyjames/ng-grid
skusunam/ng-grid
snapappointments/ui-grid
sofibraun/ng-grid
solvebio/ng-grid
songguang-2010/ng-grid
sonicparke/ng-grid
sourcec0de/ng-grid
sravanthipoujula/ng-grid
sskyy/ng-grid
stan-z/ng-grid
strider820/ng-grid
sunfirefox/ng-grid
surfer26th/ng-grid
suryasingh/ng-grid
swalters/ng-grid
tcrimi/ng-grid
tetralon/ng-grid
thedarkjester/ng-grid
tjosbon/ng-grid
tkhemani/ng-grid
tradingscreen/ng-grid
tuckerjt07/ui-grid
turn/ng-grid
uapui-dev/ng-grid
vargose/ng-grid
vladovidiu/ng-grid
wdmny/ng-grid
wp-ng/ui-grid
xordad/ng-grid
xtidt/ui-grid
xtreme-christophe/ng-grid
yangsong158/ui-grid
yanl/ng-grid
yarl/ng-grid
yesnault/ng-grid
yunmanger1/ng-grid
zelingo/ui-grid
zhangdiwaa/ng-grid
zhanghaihua/ng-grid
ztp130213/ng-grid
Nothing to show
compare: ed95cfe9d725
  • 3 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
Commits on Dec 22, 2014
The uiGridRow directive will now watch the row's compiledElementFn
property. If it changes the grid will recompile the element and swap it
out. This appears to function pretty darn quickly during vertical
scrolling.

Also added unit tests to cover swapping templates using rows processors.
Bindings were being attached to the uiGridRow scope but never removed
because the scope was not being destroyed even though child elements were
being added. This was fixed by creating new scopes for uiGridRow when
compiled/re-compiled.

Also, added an element-based `$destroy` handler for ui-grid-cell. It
already had one for the $scope.
@@ -35,7 +35,7 @@

<!-- <div class="row main"> -->
<h2>Grid</h2>
<div ui-grid="gridOptions" class="grid" ui-grid-pinning ui-grid-resize-columns></div>
<div ui-grid="gridOptions" class="grid" ui-grid-resize-columns></div>
<!-- <div class="placeholder"> -->
<!-- </div> -->

@@ -87,8 +87,8 @@ angular.module('ui.grid').directive('uiGridCell', ['$compile', '$parse', 'gridUt
rowWatchDereg();
};


$scope.$on( '$destroy', deregisterFunction );
$elm.on( '$destroy', deregisterFunction );
}
};
}
@@ -23,18 +23,46 @@
$scope.grid = uiGridCtrl.grid;
$scope.colContainer = containerCtrl.colContainer;

grid.getRowTemplateFn.then(function (templateFn) {
templateFn($scope, function(clonedElement, scope) {
$elm.replaceWith(clonedElement);
// Function for attaching the template to this scope
var clonedElement, cloneScope;
function compileTemplate() {
var compiledElementFn = $scope.row.compiledElementFn;

// Create a new scope for the contents of this row, so we can destroy it later if need be
var newScope = $scope.$new();

compiledElementFn(newScope, function (newElm, scope) {
// If we already have a cloned element, we need to remove it and destroy its scope
if (clonedElement) {
clonedElement.remove();
cloneScope.$destroy();
}

// Empty the row and append the new element
$elm.empty().append(newElm);

// Save the new cloned element and scope
clonedElement = newElm;
cloneScope = newScope;
});
}

// Initially attach the compiled template to this scope
compileTemplate();

// If the row's compiled element function changes, we need to replace this element's contents with the new compiled template
$scope.$watch('row.compiledElementFn', function (newFunc, oldFunc) {
if (newFunc !== oldFunc) {
compileTemplate();
}
});
},
post: function($scope, $elm, $attrs, controllers) {
var uiGridCtrl = controllers[0];
var containerCtrl = controllers[1];

//add optional reference to externalScopes function to scope
//so it can be retrieved in lower elements
// Sdd optional reference to externalScopes function to scope
// so it can be retrieved in lower elements
$scope.getExternalScopes = uiGridCtrl.getExternalScopes;
}
};
@@ -43,6 +43,9 @@

grid.registerColumnBuilder(service.defaultColumnBuilder);

// Row builder for custom row templates
grid.registerRowBuilder(service.rowTemplateAssigner);

// Reset all rows to visible initially
grid.registerRowsProcessor(function allRowsVisible(rows) {
rows.forEach(function (row) {
@@ -179,8 +182,49 @@
col.compiledElementFnDefer = $q.defer();

return $q.all(templateGetPromises);
}
},

rowTemplateAssigner: function rowTemplateAssigner(row) {
var grid = this;

// Row has no template assigned to it
if (!row.rowTemplate) {
// Use the default row template from the grid
row.rowTemplate = grid.options.rowTemplate;

// Use the grid's function for fetching the compiled row template function
row.getRowTemplateFn = grid.getRowTemplateFn;

// Get the compiled row template function...
grid.getRowTemplateFn.then(function (rowTemplateFn) {
// And assign it to the row
row.compiledElementFn = rowTemplateFn;
});
}
// Row has its own template assigned
else {
// Create a promise for the compiled row template function
var perRowTemplateFnPromise = $q.defer();
row.getRowTemplateFn = perRowTemplateFnPromise.promise;

// Get the row template
gridUtil.getTemplate(row.rowTemplate)
.then(function (template) {
// Compile the template
var rowTemplateFn = $compile(template);

// Assign the compiled template function to this row
row.compiledElementFn = rowTemplateFn;

// Resolve the compiled template function promise
perRowTemplateFnPromise.resolve(rowTemplateFn);
},
function (res) {
// Todo handle response error here?
throw new Error("Couldn't fetch/use row template '" + row.rowTemplate + "'");
});
}
}
};

//class definitions (moved to separate factories)
@@ -0,0 +1,97 @@
ddescribe('uiGridRow', function () {
var grid, data, columnDefs, $scope, $compile, $document, recompile, uiGridConstants, GridRow, gridUtil;

data = [
{ "name": "Bob", "age": 35 },
{ "name": "Bill", "age": 25 },
{ "name": "Sam", "age": 17 },
{ "name": "Jane", "age": 19 }
];

columnDefs = [
{ name: 'name' },
{ name: 'age' }
];

beforeEach(module('ui.grid'));

beforeEach(inject(function (_$compile_, $rootScope, _$document_, _uiGridConstants_, _GridRow_, _gridUtil_) {
$scope = $rootScope;
$compile = _$compile_;
$document = _$document_;
uiGridConstants = _uiGridConstants_;
GridRow = _GridRow_;
gridUtil = _gridUtil_;

$scope.gridOpts = {
columnDefs: columnDefs,
data: data,
onRegisterApi: function( gridApi ){ $scope.gridApi = gridApi; }
};

$scope.extScope = 'test';

recompile = function () {
grid = angular.element('<div style="width: 500px; height: 300px" ui-grid="gridOpts"></div>');

$compile(grid)($scope);

$scope.$digest();
};

recompile();
}));

describe('with different row templates', function () {
beforeEach(inject(function($templateCache) {
$templateCache.put('customRowTemplate', '<div><div>The name is: {{ row.entity.name }}</div></div>');

$scope.gridApi.grid.registerRowsProcessor(function alterTemplates(rows, cols) {
var grid = this;

rows.forEach(function (row) {
if (row.entity.name === 'Sam') {
row.rowTemplate = 'customRowTemplate';
gridUtil.getTemplate(row.rowTemplate)
.then(function (template) {
row.compiledElementFn = $compile(template);
});
}
});

return rows;
});

$scope.gridApi.grid.refresh();
$scope.$digest();
}));

it('should allow rows to compile with different templates', function() {
// The third row in the template should have a different template
var thirdRow = $(grid).find('.ui-grid-row:nth-child(3)');

expect(thirdRow.text()).toEqual('The name is: Sam');
});

it('should change templates properly after a sort', function () {
var refreshed = false;
runs(function () {
$scope.gridApi.grid.sortColumn($scope.gridApi.grid.columns[0], uiGridConstants.ASC)
.then(function () {
$scope.gridApi.grid.refresh();
refreshed = true;
});

$scope.$digest();
});

waitsFor(function () { return refreshed; }, 10000);

runs(function () {
var fourthRow = $(grid).find('.ui-grid-row:nth-child(4)');

expect(fourthRow.text()).toEqual('The name is: Sam');
});
});
});
});

No commit comments for this range

You can’t perform that action at this time.