Skip to content

Commit df14f33

Browse files
authored
Merge pull request #71 from dkamburov/master
Remove substring when updating cells, add test for it, closes #69
2 parents ec1eedc + 809eebb commit df14f33

File tree

3 files changed

+70
-12
lines changed

3 files changed

+70
-12
lines changed

src/igniteui-angular.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,7 @@
327327
td = grid.cellById(record[ pkKey ], diff[ i ].txlog[ j ].key);
328328
if (column.template || grid.options.rowTemplate) {
329329
newFormattedVal = grid
330-
._renderTemplatedCell(diff[ i ].txlog[ j ].newVal, column)
331-
.substring(1);
330+
._renderTemplatedCell(diff[ i ].txlog[ j ].newVal, column);
332331
} else {
333332
newFormattedVal = grid
334333
._renderCell(diff[ i ].txlog[ j ].newVal, column, record);
@@ -365,6 +364,8 @@
365364

366365
// igHierarchicalGrid specific code for one way data binding
367366
$.ig.angular.igHierarchicalGrid = $.ig.angular.igHierarchicalGrid || {};
367+
$.ig.angular.igHierarchicalGrid.element = $.ig.angular.igHierarchicalGrid.element ||
368+
"<table></table>";
368369
$.ig.angular.igHierarchicalGrid.bindEvents = $.ig.angular.igHierarchicalGrid.bindEvents ||
369370
function (scope, element, attrs) {
370371
var unbinder;
@@ -480,6 +481,14 @@
480481
});
481482
};
482483

484+
// igTreeGrid specific code instantiating the element on table
485+
$.ig.angular.igTreeGrid = $.ig.angular.igTreeGrid || {};
486+
$.ig.angular.igTreeGrid.element = $.ig.angular.igTreeGrid.element || "<table></table>";
487+
488+
// igPivotGrid specific code instantiating the element on table
489+
$.ig.angular.igPivotGrid = $.ig.angular.igPivotGrid || {};
490+
$.ig.angular.igPivotGrid.element = $.ig.angular.igPivotGrid.element || "<table></table>";
491+
483492
// Utility functions
484493
function convertToCamelCase(str) {
485494
//convert hyphen to camelCase

test/e2e/scenarios.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,39 @@ describe("my app", function() {
573573
expect(util.getResult('$("#grid1 tbody tr:eq(1) td")[2].innerHTML'))
574574
.toBe(util.getResult('angular.element("#grid1").scope().northwind[1].UnitsOnOrder.toString()'));
575575
});
576+
577+
it("should apply column template correctly", function () {
578+
util.resetNorthwindScope();
579+
util.executeScript('$("#grid1").igGrid("destroy");');
580+
util.executeScript('$("#grid1").remove();');
581+
util.executeScript('angular.element("body").scope().addGrid(\''
582+
+ '<ig-grid id="grid1" data-source="northwind" height="400px" primary-key="ProductID" auto-commit="true" width="700px" auto-generate-columns="false">'
583+
+ '<columns>'
584+
+ '<column key="ProductID" header-text="Product ID" width="200px" data-type="number"></column>'
585+
+ '<column key="ProductName" header-text="Name" width="300px" data-type="string"></column>'
586+
+ '<column key="QuantityPerUnit" header-text="Quantity per unit" width="200px" data-type="string"></column>'
587+
+ '<column key="UnitsOnOrder" header-text="Units on order" width="200px" data-type="number" template="<span>${UnitsOnOrder}</span>"></column>'
588+
+ '</columns>'
589+
+ '<features>'
590+
+ '<feature name="Updating">'
591+
+ '<column-settings>'
592+
+ '<column-setting column-key="ProductID" read-only="true">'
593+
+ '</column-settings>'
594+
+ '</column-settings>'
595+
+ '</feature>'
596+
+ '</features>'
597+
+ '</ig-grid>'
598+
+ '\');'
599+
);
600+
//the template should be initialized correctly
601+
expect(util.getResult('$("#grid1 tbody tr:eq(1) td")[3].innerHTML'))
602+
.toBe('<span>40</span>');
603+
util.executeScript('angular.element("#grid1").scope().northwind[1].UnitsOnOrder = 200;');
604+
util.executeScript('angular.element("#grid1").scope().$apply();');
605+
//the template should be applied correctly after changes in scope`
606+
expect(util.getResult('$("#grid1 tbody tr:eq(1) td")[3].innerHTML'))
607+
.toBe('<span>200</span>');
608+
});
576609
});
577610

578611
describe("Tree", function() {

test/unit/directiveSpecs.js

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,25 +131,41 @@ describe("Ignite directives", function() {
131131
expect(dataChartElement.length).toBe(1);
132132
expect(dataChartElement.data("igDataChart")).not.toBeUndefined();
133133
}));
134-
134+
135135
it("should create hierarchical grid", inject(function($compile, $rootScope) {
136-
var hierarchicalGridTpl ='<ig-hierarchical-grid id="hgrid1" data-source="northwindEmployees" width="100%" height="400px" auto-commit="true" auto-generate-columns="false" auto-generate-layouts="false">' +
137-
'<columns> <column key="FirstName" header-text="First Name" width="25%" data-type="string"></column>' +
136+
var hierarchicalGridTpl =
137+
'<ig-hierarchical-grid id="hgrid1" data-source="data" width="100%" height="400px" auto-commit="true" auto-generate-columns="false" auto-generate-layouts="false">' +
138+
'<columns>' +
139+
'<column key="FirstName" header-text="First Name" width="25%" data-type="string"></column>' +
138140
'<column key="LastName" header-text="Last Name" width="25%" data-type="string"></column>' +
139141
'<column key="Title" header-text="Title" width="25%" data-type="string"></column>' +
140-
'<column key="BirthDate" header-text="Birth Date" width="25%" data-type="date"></column></columns>' +
141-
'<column-layouts><column-layout key="Orders" response-data-key="results" primary-key="OrderID" auto-generate-columns="false" width="100%">' +
142-
'<columns><column key="OrderID" header-text="OrderID" width="25%" data-type="string"></column>' +
143-
'<column key="Freight" header-text="Freight" width="25%" data-type="string"></column>' +
144-
'<column key="ShipName" header-text="ShipName" width="25%" data-type="string"></column>' +
145-
'<column key="ShipAddress" header-text="ShipAddress" width="25%" data-type="string"></column></columns>' +
146-
'<features><feature name="Paging" page-size="10"></feature></features></column-layout></column-layouts>ig-hierarchical-grid>';
142+
'<column key="BirthDate" header-text="Birth Date" width="25%" data-type="date"></column>' +
143+
'</columns>' +
144+
'<features>' +
145+
'<feature name="Selection" mode="row"></feature>' +
146+
'</features>' +
147+
'<column-layouts>' +
148+
'<column-layout key="Orders" response-data-key="results" primary-key="OrderID" auto-generate-columns="false" width="100%">' +
149+
'<columns>' +
150+
'<column key="OrderID" header-text="OrderID" width="25%" data-type="string"></column>' +
151+
'<column key="Freight" header-text="Freight" width="25%" data-type="string"></column>' +
152+
'<column key="ShipName" header-text="ShipName" width="25%" data-type="string"></column>' +
153+
'<column key="ShipAddress" header-text="ShipAddress" width="25%" data-type="string"></column>' +
154+
'</columns>' +
155+
'<features>' +
156+
'<feature name="Paging" page-size="10"></feature>' +
157+
'</features>' +
158+
'</column-layout>' +
159+
'</column-layouts>' +
160+
'</ig-hierarchical-grid>';
161+
147162
var hierarchicalGrid = angular.element('<div ng-app="my-app"><div ng-controller="NorthwindCtrl">' + hierarchicalGridTpl + '</div>');
148163
var scope = $rootScope.$new();
149164
$compile(hierarchicalGrid)(scope);
150165
scope.$digest();
151166
var hGridElement = hierarchicalGrid.find("#hgrid1");
152167
expect(hGridElement.length).toBe(1);
153168
expect(hGridElement.data("igHierarchicalGrid")).not.toBeUndefined();
169+
expect(hGridElement.data("igGridSelection")).not.toBeUndefined();
154170
}));
155171
});

0 commit comments

Comments
 (0)