Checkboxes in a batch grid require an extra click to put them into Edit mode, but that's fixed with this code I got on this forum...
function
changeEditor(sender) {
var
grd = GetControlRAD(
"grdPODetails"
);
var
batchManager = grd.get_batchEditingManager();
batchManager.openCellForEdit(sender.parentElement.parentElement);
sender.checked = !sender.checked;
}
<
telerik:RadGrid
ID
=
"grdPODetails"
runat
=
"server"
AllowSorting
=
"True"
AutoGenerateColumns
=
"False"
Skin
=
"Office2010Blue"
GridLines
=
"None"
>
<
HeaderContextMenu
EnableAutoScroll
=
"True"
>
</
HeaderContextMenu
>
<
MasterTableView
CommandItemDisplay
=
"Top"
EditMode
=
"Batch"
InsertItemDisplay
=
"Bottom"
ClientDataKeyNames
=
"PurchaseOrderDetailKey"
DataKeyNames
=
"PurchaseOrderDetailKey"
>
<
BatchEditingSettings
EditType
=
"Cell"
OpenEditingEvent
=
"Click"
/>
<
CommandItemSettings
ShowRefreshButton
=
"False"
ShowSaveChangesButton
=
"true"
ShowCancelChangesButton
=
"true"
/>
<
NoRecordsTemplate
>
No detail lines to display.
</
NoRecordsTemplate
>
<
Columns
>
<
telerik:GridTemplateColumn
DataField
=
"PrintOnPurchaseOrder"
HeaderText
=
"Print"
UniqueName
=
"PrintOnPurchaseOrder"
DataType
=
"System.Boolean"
>
<
HeaderStyle
Width
=
"40px"
/>
<
ItemStyle
Width
=
"40px"
/>
<
ItemTemplate
>
<
input
id
=
"chkPrint"
type
=
"checkbox"
checked='<%# Eval("PrintOnPurchaseOrder") %>' onclick="changeEditor(this);" />
</
ItemTemplate
>
<
EditItemTemplate
>
<
asp:CheckBox
ID
=
"chkPrint"
runat
=
"server"
Checked='<%# Bind("PrintOnPurchaseOrder") %>' />
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
DataField
=
"PostToGeneralLedger"
HeaderText
=
"Post"
UniqueName
=
"PostToGeneralLedger"
DataType
=
"System.Boolean"
>
<
HeaderStyle
Width
=
"40px"
/>
<
ItemStyle
Width
=
"40px"
/>
<
ItemTemplate
>
<
input
id
=
"chkPost"
type
=
"checkbox"
checked='<%# Eval("PostToGeneralLedger") %>' onclick="changeEditor(this);" />
</
ItemTemplate
>
<
EditItemTemplate
>
<
asp:CheckBox
ID
=
"chkPost"
runat
=
"server"
Checked='<%# Bind("PostToGeneralLedger") %>' />
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
DataField
=
"UnitDescription"
UniqueName
=
"UnitDescription"
HeaderText
=
"Unit Desc"
DataType
=
"System.String"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblUnitDescription"
runat
=
"server"
Text='<%# Eval("UnitDescription") %>'>
</
asp:Label
>
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadTextBox
ID
=
"txtUnitDescription"
runat
=
"server"
MaxLength
=
"10"
Width
=
"100%"
Text='<%# Bind("UnitDescription") %>' >
</
telerik:RadTextBox
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
AllowKeyboardNavigation
=
"true"
>
<
Selecting
AllowRowSelect
=
"True"
/>
<
ClientEvents
/>
</
ClientSettings
>
</
telerik:RadGrid
>
A breakpoint in changeEditor shows it's only called once, to put it in edit mode. But the first time you click it (and every time following if you keep clicking it while still in edit mode) I need to handle that event. For instance, in this grid, if I check the checkbox in the 2nd column, how can I set column "UnitDescription" in the same row to "A", but if I uncheck the checkbox (while still in EditMode) it sets UnitDescription" to "B"?
I tried putting an event handler on the checkbox within EditItemTemplate, but that didn't work... or I did it wrong. It's almost like when it opens in edit mode, a new checkbox is created on the fly. But I can't figure out where it is or how to grab its events. Please help.