Accessing Controls
With "Mobile" RenderMode you can access controlsin the same manner as with the other rendering mode with only few specific to themobile rendering scenarios. One difference that you should consider is that thecontrols type is different from the other render modes.
Accessing column editors in PopUp edit mode
With the default setting of the mobile rendering, all columns will render native controlsand you should have that in mind when you try to get reference to column editors.
With edit modes EditForms, InPlace and Batch,getting reference to column editors is exactly the same as with the other render modes, but a major difference is introduced in PopUp edit mode. The mobile PopUp editing introducesnew edit menu, which renders a completely different layout and controls structure.
The following examples demonstrate how to get reference to native column editors in PopUp edit mode and native controls:
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<telerik:RadGrid runat="server" ID="RadGrid1" OnNeedDataSource="RadGrid_NeedDataSource"
RenderMode="Mobile" OnItemCreated="RadGrid1_ItemCreated">
<MasterTableView CommandItemDisplay="Top" EditMode="PopUp" AutoGenerateColumns="false">
<Columns>
<telerik:GridEditCommandColumn></telerik:GridEditCommandColumn>
<telerik:GridNumericColumn DataField="ID" HeaderText="ID"></telerik:GridNumericColumn>
<telerik:GridBoundColumn DataField="Name" HeaderText="Name"></telerik:GridBoundColumn>
<telerik:GridDateTimeColumn DataField="Date" HeaderText="Date"></telerik:GridDateTimeColumn>
<telerik:GridCheckBoxColumn DataField="Active" HeaderText="Active"></telerik:GridCheckBoxColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
{
GridEditFormItem item = e.Item as GridEditFormItem;
TextBox idEditor = item.EditFormCell.FindControl("ID").Controls[0] as TextBox;
TextBox lastNameEditor = item.EditFormCell.FindControl("Name").Controls[0] as TextBox;
TextBox dateEditor = item.EditFormCell.FindControl("Date").Controls[0] as TextBox;
CheckBox boolEditor = item.EditFormCell.FindControl("Active").Controls[0] as CheckBox;
}
}
protected void RadGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
DataTable table = new DataTable();
table.Columns.Add("ID", typeof(int));
table.Columns.Add("Name", typeof(string));
table.Columns.Add("Date", typeof(DateTime));
table.Columns.Add("Active", typeof(Boolean));
for (int i = 0; i < 5; i++)
{
table.Rows.Add(i, "Name" + i, DateTime.Now.AddDays(i), i % 2 == 0);
}
(sender as RadGrid).DataSource = table;
}
When you want to render the standard editors for a column and you are setting the UseNativeEditorsInMobileMode property of a GridEditableColumnto "false", each column from the above example will render editors corresponding to the column type (for example, the GridNumericColumn will have a RadNumericTextBox as an editor, the GridDateTimeColumn will have RadDatePicker, etc.).