model | max. load |
M1 | 101.0 |
M2 | 10.8 |
M3 | 9.2 |
M4 | 98.5 |
M5 | 81.5 |
when sorting fo "max. load" I get the following:
model | max. load |
M2 | 10.8 |
M1 | 101.0 |
M5 | 81.5 |
M3 | 9.2 |
M4 | 98.5 |
model | max. load |
M3 | 9.2 |
M2 | 10.8 |
M5 | 81.5 |
M4 | 98.5 |
M1 | 101.0 |
Hi
Your guess was right. Is there a way to enforce that the fields of a column are handeld as numeric values?
Thanks for helping.
Regards
Bernd
<div ng-app="employeeView">
<div ng-controller="GridCtrl">
<div ej-grid id="Grid" allowfiltering="true" allowmultisorting="true" allowpaging="true" e-allowsorting="true" e-datasource="data" e-load="load" selectiontype="single"
allowselection="true">
<div e-columns>
<div e-column e-field="OrderID" e-headertext="Order ID" e-isprimarykey="true" e-textalign="right"></div>
<div e-column e-field="Freight" e-headertext="Freight" e-textalign="right" type="number" format="{0:n2}"></div>
</div>
</div>
</div>
</div>
<script>
angular.module('employeeView', ['ejangular'])
.controller('GridCtrl', function ($scope) {
$scope.tools = ["add", "edit", "delete", "update", "cancel"];
$scope.page = 2;
$scope.load = function (args) {
for (var i = 0; i < this.model.dataSource().length ; i++) {
this.model.dataSource()[i]["Freight"] = parseInt(this.model.dataSource()[i]["Freight"])
}
}
$scope.data = [{ OrderID: "M1", Freight: "101.0" }, { OrderID: "M2", Freight: "10.8" }, { OrderID: "M3", Freight: "9.2" }, { OrderID: "M4", Freight: "98.5" }, { OrderID: "M5", Freight: "81.5" }];
});
</script> |
the example given is not Angular 2. since we don't have controllers anymore. Can you post an example for this in Angular? Thank you so much.
<ej-grid #grid [dataSource]="gridData" (load)="gridLoad($event)">
<e-column field="Geraet" headerText="model" [visible]="true"></e-column>
<e-column field="maxLast" headerText="max. load" type="number" format="{0:n2}"></e-column>
</ej-grid>
public gridLoad(args){
for (var i = 0; i < args.model.dataSource.length ; i++) {
args.model.dataSource[i]["maxLast"] = parseInt(args.model.dataSource[i]["maxLast"])
}
}
public gridData = [
{ OrderID: "M1", Freight: "101.0" },
{ OrderID: "M2", Freight: "10.8" },
{ OrderID: "M3", Freight: "9.2" },
{ OrderID: "M4", Freight: "98.5" },
{ OrderID: "M5", Freight: "81.5" }
]; |