Hello,
I am trying to get the record count of the grid using "grid.dataSource.total()", but it is always returning zero.
This is an AngularJS app with an itemDetailsDirective that is used to display detail about an item. It is a pop-up window that contains a grid with inventory on-hand, etc. for the various locations. However, when no locations have inventory, the grid is displayed with only the headers, which looks funny and I would like to only display the grid if there are records to display, and display some text like, "No inventory found for this item" instead of the grid when it is empty.
Here is the directive:
How can I get the record count of the grid / data source?
Also, please let me know if you have other recommendations for displaying something alternate when the grid is empty.
Thanks,
Lars
I am trying to get the record count of the grid using "grid.dataSource.total()", but it is always returning zero.
This is an AngularJS app with an itemDetailsDirective that is used to display detail about an item. It is a pop-up window that contains a grid with inventory on-hand, etc. for the various locations. However, when no locations have inventory, the grid is displayed with only the headers, which looks funny and I would like to only display the grid if there are records to display, and display some text like, "No inventory found for this item" instead of the grid when it is empty.
Here is the directive:
(function () { 'use strict'; angular.module('app').directive('itemDetails', itemDetailsDirective); function itemDetailsDirective() { return { restrict: 'E', scope: { itemNo: "@", }, templateUrl: "/app/inventory/itemDetails.html", controller: function ($scope, $element) { console.log("itemDetailsDirective, controller: " + $scope.itemNo); $scope.$on('ShowDetails', function (event, itemNo) { console.log("itemDetailsDirective, ShowDetails: " + itemNo); $scope.itemNo = itemNo; $scope.inventoryGridOptions = getInventoryGridOptions(); $scope.inventoryGrid.setDataSource(getGridDataSource(itemNo)); $scope.inventoryGrid.dataSource.read(); $scope.gridRecordCount = $scope.inventoryGrid.dataSource.total(); $scope.inventoryGrid.refresh(); $scope.itemDetailsWindow.center(); $scope.itemDetailsWindow.open(); }); $scope.onGridDataBound = function(e) { if ($scope.inventoryGrid) { $scope.gridRecordCount = $scope.inventoryGrid.dataSource.total(); } } $scope.close = function() { $scope.itemDetailsWindow.close(); } } }; function getGridDataSource(itemNo) { console.log("itemDetailsDirective, getGridDataSource: " + itemNo); return new kendo.data.DataSource({ type: "json", transport: { read: { url: "/api/Inventory/GetInventory?itemNo=" + itemNo, type: "GET", cache: false } }, sort: [{ field: "Loc", dir: "asc" }], pageSize: 10 }); } function getInventoryGridOptions() { return { scrollable: false, columns: [ { field: "Loc", title: "Loc", width: 50, }, { field: "QtyOnHand", title: "Qty OnHand", width: 70, format: "{0:n0}", attributes: { style: "text-align:right" } }, { field: "QtyCom", title: "Qty Com", width: 50, format: "{0:n0}", attributes: { style: "text-align:right" } }, { field: "QtyBO", title: "Qty BO", width: 50, format: "{0:n0}", attributes: { style: "text-align:right" } }, { field: "QtyXfer", title: "Qty Xfer", width: 50, format: "{0:n0}", attributes: { style: "text-align:right" } }, { field: "QtyOrd", title: "Qty Ord", width: 50, format: "{0:n0}", attributes: { style: "text-align:right" } } ] }; }; };})();How can I get the record count of the grid / data source?
Also, please let me know if you have other recommendations for displaying something alternate when the grid is empty.
Thanks,
Lars