let grid: Grid = new Grid(
{
dataSource: [],
editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true, mode: 'Normal', newRowPosition: 'Top' },
allowPaging: true,
dataBound: function(args){
if(grid.getCurrentViewRecords().length > 0)// to disbale the add toolbar during intial rendering
grid.toolbarModule.enableItems(["Grid_add"],false);
},
actionComplete: function(args){
if(args.requestType == "save"){// to disbale the toolbar when a record is added
setTimeout(function(args){
grid.toolbarModule.enableItems(["Grid_add"],false);
}.bind(grid),0)
}
},
pageSettings: { pageCount: 5 },
………………………….
});
grid.appendTo('#Grid'); |
<script type="text/javascript">
$(function () {
$("#Grid").ejGrid({
dataSource: window.gridData,
dataBound: function (args) {
if (this.model.currentViewData.length > 0)
$("#Grid_add").addClass("e-disable") // Use your grid ID here.
},
allowPaging: true,
editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true },
toolbarSettings: { showToolbar: true, toolbarItems: [ej.Grid.ToolBarItems.Add, ej.Grid.ToolBarItems.Edit, ej.Grid.ToolBarItems.Delete, ej.Grid.ToolBarItems.Update, ej.Grid.ToolBarItems.Cancel] },
columns: [
………………………………………….
]
});
});
</script> |