Hi,
I am a experience developer but a completely Kendo newbie and doing some initial tests to see if this can be a platform for our application. I have gotten a grid to work loading data from my database. But, I cannot get sorting for function for the numeric column, it always sorts as a string. I have created a model where the data type is set as number, and according to my understanding this should now parse the json data into that model and then the grid should know that this is a number, but it stills sorts as a string. Data comes from json, one line looks like this:
{"orderId":"65-68455-0b0b7","transact":"414583245","id":"414583245","paytype":"VISA","amount":"7200.00","amountBase":720000,"currency":"NOK","currencyCode":578,"test":"1","time":"2011-03-03 21:53:15","cardnomask":"XXXXXXXXXXXX0000","cardcountry":null,"refunded":0,"refundable":720000,"pids":[68455],"receipt":{"68455":false},"persons":"KEtil Test"}
My code looks like this:
I am a experience developer but a completely Kendo newbie and doing some initial tests to see if this can be a platform for our application. I have gotten a grid to work loading data from my database. But, I cannot get sorting for function for the numeric column, it always sorts as a string. I have created a model where the data type is set as number, and according to my understanding this should now parse the json data into that model and then the grid should know that this is a number, but it stills sorts as a string. Data comes from json, one line looks like this:
{"orderId":"65-68455-0b0b7","transact":"414583245","id":"414583245","paytype":"VISA","amount":"7200.00","amountBase":720000,"currency":"NOK","currencyCode":578,"test":"1","time":"2011-03-03 21:53:15","cardnomask":"XXXXXXXXXXXX0000","cardcountry":null,"refunded":0,"refundable":720000,"pids":[68455],"receipt":{"68455":false},"persons":"KEtil Test"}
My code looks like this:
$(document).ready(
function
() {
var
transactionModel = kendo.data.Model.define({
fields: {
id:
"transact"
,
persons: {
editable:
false
},
time: {
editable:
false
,
type:
"date"
,
},
transact: {
editable:
false
},
amount: {
editable:
false
,
type:
"number"
,
},
}
});
var
dataSource =
new
kendo.data.DataSource({
transport : {
read :
"/wwwdocs/ajax.php"
,
schema : {
data : transactionModel
},
},
}
);
$(
function
() {
$(
"#transactions"
).kendoGrid({
dataSource : dataSource,
columns : [ {
field :
"persons"
,
title :
"Navn"
,
width : 300
}, {
field :
"time"
,
title :
"Tid"
,
width : 160,
}, {
field :
"transact"
,
title :
"Transaksjons-id"
,
width : 160
}, {
field :
"amount"
,
title :
"Sum"
,
width : 160
}, ],
filterable :
true
,
sortable :
true
,
groupable:
true
,
});
});
});