I have my Radgrid defined with the master table in Batch mode as follows:
<
telerik:RadGrid
ID
=
"EventSubjects"
CssClass
=
"eventSubjectsGrid"
ShowStatusBar
=
"true"
AutoGenerateColumns
=
"False"
GridLines
=
"Both"
AllowPaging
=
"True"
PagerStyle-AlwaysVisible
=
"true"
OnNeedDataSource
=
"EventSubjects_NeedDataSource"
OnBatchEditCommand
=
"EventSubjects_BatchEditCommand"
Skin
=
"Sunset"
runat
=
"server"
GroupPanelPosition
=
"Top"
>
<
ClientSettings
AllowKeyboardNavigation
=
"true"
>
<
Selecting
AllowRowSelect
=
"True"
/>
<
ClientEvents
OnCommand
=
"gridCommand"
/>
</
ClientSettings
>
<
ValidationSettings
EnableValidation
=
"true"
CommandsToValidate
=
"PerformInsert,Update,UpdateEdited,saveChanges,BatchEdit"
></
ValidationSettings
>
<
MasterTableView
EditMode
=
"Batch"
CommandItemDisplay
=
"Bottom"
DataKeyNames
=
"PhotoSubjectID,EventPhotoSubjectID,EventPhotoSessionID"
>
<
BatchEditingSettings
EditType
=
"Cell"
/>
In the ClientEvents OnCommand js function I am trying to the the Data Key for the current DataGridItem, but it comes back null (rowPhotoSessionID . When I check the masterTableView, masterTable.get_clientDataKeyNames(), it returns an empty array.
function
gridCommand(sender, args) {
if
(args.get_commandName() ==
"BatchEdit"
) {
var
masterTable = sender.get_masterTableView();
var
batchManager = sender.get_batchEditingManager();
var
dataItems = masterTable.get_dataItems();
var
validationFails =
false
;
for
(
var
i = 0; i < dataItems.length; i++) {
var
barcodeCell = dataItems[i].get_cell(
"Barcode"
);
var
barcodeValue = batchManager.getCellValue(barcodeCell);
var
rowPhotoSessionID = dataItems[i].getDataKeyValue(
"PhotoSubjectID"
);
.
.
How do I get the DataKeys for the current DataGridRow in this situation?
In case you are wondering, I am trying to do validation when the user clicks the 'Save Changes' button in BatchEdit mode, by passing the barcodes on the page to the server in an ajax call, and then update the cells that are invalid. So, I need both the barcode value and the PhotoSubjectID so that I can tell which barcodes changed.
I looked all over to find a property or method that would return me JUST the edited data values, I found this forum entry Batch Editing - Need to have the save changes button outside the grid , that said that this internal collection has the edited data, but did not recommend using it.
$find(
'RadGrid1'
).get_batchEditingManager()._changes
Is there some other way, in BatchEdit mode to get the edited values on the Client side so that I can do validation?