1. Create datasource (transport and read)
2. Create ListView, and bind to datasource with specified template
3. create var to get recordCount using myDataSource.total()
4. Display recordCount
There's nothing wrong with what you are doing. Just know that dataSource.total() won't be populated until it has been fetched. Putting this item after the ListView bind doesn't mean it will happen in that order. The transport is happening asynchronously. The datasource/listview does not currently doesn't expose an event for onAfterDatabound or the like. Just use my fetch code instead. Datasource is smart enough not to query the data twice unless it needs to.
I've found that you can also create a function for datasource's change event. In my use it is a better way to track changes for dynamic data than using a manual fetch.
Sorry but this never worked for me
var dataSource2 = new kendo.data.DataSource({
dataType: "json",
serverFiltering: true,
transport: {
read: "http://opendata.cbs.nl/ODataApi/odata/37296ned/TypedDataSet"
},
schema: {
data: function (data) {
return data.value;
}
2. Execute the following code in the browser's Javascript console:
var dataSource2 = $("#grid").data("kendoGrid").dataSource;
dataSource2.fetch(function () {
alert(dataSource2.total());
alert(dataSource2.totalPages());
});
In your case, are you sure that your schema is correct and there is a valid server response? If you need further assistance, please send a runnable example.
Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
console.log(
'Fetching...'
);
ds.fetch(
function
(){
console.log(
'Actually fetched'
);
console.log(ds.total());
console.log(ds.totalPages());
});
1. Create datasource (transport and read)
2. Create ListView, and bind to datasource with specified template
3. create var to get recordCount using myDataSource.total()
4. Display recordCount
Let me know if I need to use a different order.
thx.