If a grid has no records I do not want to display the grid at all (including the headers) but would like to display a text message instead. Is this possible using Kendo?
Thanks
1 Answer, 1 is accepted
0
Alexander Valchev
Telerik team
answered on 17 Jul 2012, 04:17 PM
Hello Simon,
To achieve this I recommend hooking up to the change event of the dataSource and creating the grid only if there are records. For example:
var dataSource = new kendo.data.DataSource({
//....
change: function() {
if ( this.data().length ) {
createGrid();
} else {
//display message
}
}
});
function createGrid() {
$("#grid").kendoGrid({
dataSource: dataSource,
//...
});
}
When you use this approach please consider the following cases:
the event throws after each change in the dataSource records, not only after the data is fetched from the server, so you have to assure that the grid will be initialized only once
the dataSource have to be read manually as there is no widget bound to it - dataSource.read();
I hope this helps.
Kind regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!