Hello,
I have a radgrid in Batch Edit mode that I want to perform some validation on before postback. This worked for me just fine when the grid was one level (no children), but if I want to add a second level to the hierarchy (one child) then the validation causes code errors.
This seems to come from SaveAllHierarchyLevels="true". When this is true, it causes the args.set_cancel(true) in the validation step to create issues if the same line is edited and fixed after failing validation, then saved. I believe it has something to do with the differences between the BatchEdit command and the GlobalBatchEdit command.
Is there something I need to do to implement client-side GlobalBatchEdit validation specifically, that is not part of BatchEdit validation?
function ValidateCommand(sender, args) { var failed = false; var indic = ""; //alert(totals[0] + " " + totals[1] + " " + totals[2] + " " + totals[3] + " " + totals[4] + " " + totals[5] + " " + totals[6]); checksum(); for (var i = 0; i < 7; i++) { if (totals[i] > 24.0) { failed = true; indic += "Too much time entered! Cannot have more than 24 hours per day. \n"; break; } } var radGrid = $find('<%= WeeklyTimeGrid.ClientID %>'); var batchManager = radGrid.get_batchEditingManager(); var masterTable = radGrid.get_masterTableView(); var rows = masterTable.get_dataItems(); var size = rows.length; for (i = 0; i < size; i++) { var s = masterTable.getCellByColumnUniqueName(rows[i], "Phase"); //alert("(" + s.innerText.trim() + ")"); if (s.innerText.trim() == "") { indic += "Phase code is required!\n"; failed = true; break; } } //alert(failed + " " + args.get_commandName() + " " + args.get_commandArgument()); if (failed && args.get_commandName() == "BatchEdit") { //<--Becomes 'GlobalBatchEdit' args.set_cancel(true); alert(indic); } }
protected void WeeklyTimeGrid_BatchEditCommand(object sender, GridBatchEditingEventArgs e) { string a = _BatchID; //refresh batch info from db SavedChangesList.Visible = true; //If the batch is locked... if (readyToExport != 0 || hasBeenExported != 0) { //...don't do anything e.Canceled = true; NotifyUser("The batch was locked by another user, or has been exported"); if (WeeklyTimeGrid.Enabled) { ToggleBatchLock(); } return; } foreach (GridBatchEditingCommand c in e.Commands) {//Here is where GlobalBatchEdit fails and BatchEdit is fine (after failing validation once, then correcting and saving) if (c.Item == null) { c.Canceled = true; NotifyUser("There was an error updating time, please try again. If the problem persists, please contact IT."); } } UpdateSelectedEmpTime(e.Commands); }