I am using Angular Kendo and building one list.
<kendo-mobile-list-view id="myList" class="item-list" k-template="templates.myListTemp" k-data-source="myService.myDataSource">
</kendo-mobile-list-view>
I am using Kendo DataSource
and ObservableArray
for generating data for my list in my service.
this.myDataSource = new kendo.data.DataSource({ data:this.myObservableArray });
this.myObservableArray.push({ key: "test", id:"test" });
Every is working as expected.
Now I want to display a message when their are no records to display, in the place I am displaying the list, like "NO RECORDS TO DISPLAY, Please Refresh".
How can I achieve this using angular Kendo.
I saw few posts for Kendo JQuery but no solution for Angular Kendo.
Define the grid
$('#grid').kendoGrid({ dataSource: employeeDataSource, dataBound: function () { DisplayNoResultsFound($('#grid')); },
The javascript function 'DisplayNoResultsFound' is as follows
function DisplayNoResultsFound(grid) { // Get the number of Columns in the grid var dataSource = grid.data("kendoGrid").dataSource; var colCount = grid.find('.k-grid-header colgroup > col').length; // If there are no results place an indicator row if (dataSource._view.length == 0) { grid.find('.k-grid-content tbody') .append('<tr class="kendo-data-row"><td colspan="' + colCount + '" style="text-align:center"><b>No Results Found!</b></td></tr>'); } // Get visible row count var rowCount = grid.find('.k-grid-content tbody tr').length; // If the row count is less that the page size add in the number of missing rows if (rowCount < dataSource._take) { var addRows = dataSource._take - rowCount; for (var i = 0; i < addRows; i++) { grid.find('.k-grid-content tbody').append('<tr class="kendo-data-row"><td> </td></tr>'); } } }
First, you should add a name to your kendo instance( myList
):
<kendo-mobile-list-view="myList" id="myList" class="item-list" k-template="templates.myListTemp" k-data-source="myService.myDataSource">
</kendo-mobile-list-view>
Then, in your controller:
$scope.myList.bind('dataBound',DisplayNoResultsFound)
Also you could specify some k-options
in the html and read those options(including the dataBound
) from the angular controller, this link explains more about it
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.