$("#Grid").ejGrid({
// the datasource "window.gridData" is referred from jsondata.min.js
dataSource: window.gridData,
allowPaging: true,
rowSelecting: function(args){
if(this.getContentTable().find(".gridform").length) //to check whether there is edit form or not
args.cancel = 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: [
…………………………………………………………….
}); |
$("#Grid").ejGrid({
// the datasource "window.gridData" is referred from jsondata.min.js
dataSource: window.gridData,
allowPaging: true,
actionBegin: function(args){
if(args.requestType == "paging"){
if(this.getContentTable().find(".gridform").length){
args.cancel = true;// prevent the default paging action
alert("record is being edited"); // alert the user
var pag = this.getPager().ejPager("instance");
pag.setModel({currentPage: args.previousPage});
}
}
},
enableAutoSaveOnSelectionChange: false,
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: [
……………………………………………………………………………..
]
}); |
$(function () {
$("#Grid").ejGrid({
// the datasource "window.gridData" is referred from jsondata.min.js
dataSource: window.gridData,
allowPaging: true,
allowSorting: true,
allowReordering: true,
showColumnChooser: true,
allowFiltering: true,
rowDragStart: function (args) {
if (this.getContentTable().find(".gridform").length)
args.cancel = true;
},
columnDragStart: function (args) {
if (this.getContentTable().find(".gridform").length)
args.cancel = true;
},
actionBegin: function (args) {
if (args.requestType != "cancel" && args.requestType != "save") {
if (!ej.isNullOrUndefined(this.getContentTable())) {
if (this.getContentTable().find(".gridform").length) {
args.cancel = true;
alert("record is being edited");
if (args.requestType == "paging") {
var pag = this.getPager().ejPager("instance");
pag.setModel({ currentPage: args.previousPage })
}
}
}
}
},
rowSelecting: function (args) {
if (this.getContentTable().find(".gridform").length) //to check whether there is edit form or not
args.cancel = true;
},
………………………………………………………………………..
columns: [
………………………………………………………………………….
]
});
}); |