6 Answers, 1 is accepted
You can utilize the client-side API of the button - $find("ButtonID").set_checked(true)
Regards,
Danail Vasilev
Telerik
how to keep selected multiple rows and not lose the selection to apply filters or pass between pages
<telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="-1" DataSourceID="SqlDataSource1" GridLines="Both" AllowMultiRowSelection="true" GroupPanelPosition="Top" AllowFilteringByColumn="True" AllowPaging="True" Font-Size="XX-Small" PageSize="5">
<GroupingSettings CollapseAllTooltip="Collapse all groups"></GroupingSettings>
<ClientSettings>
<Selecting AllowRowSelect="True" />
<Resizing AllowColumnResize="True" AllowResizeToFit="True" />
</ClientSettings>
<AlternatingItemStyle Font-Size="Small" />
<MasterTableView AutoGenerateColumns="False" DataKeyNames="IDENT_ASOC" DataSourceID="SqlDataSource1">
<Columns>
<telerik:GridClientSelectColumn UniqueName="Seleccionar">
</telerik:GridClientSelectColumn>
<telerik:GridBoundColumn DataField="IDENT_ASOC" HeaderText="ID CLIENTE" ReadOnly="True" SortExpression="IDENT_ASOC" UniqueName="IDENT_ASOC" AllowFiltering="False" AllowSorting="False">
<HeaderStyle Width="100px" />
<ItemStyle Width="100px"/>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="NOM_ASOC" FilterControlAltText="Filter NOM_ASOC column" HeaderText="CLIENTE" SortExpression="NOM_ASOC" UniqueName="NOM_ASOC">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
<ItemStyle Font-Size="Small" />
</telerik:RadGrid>
<telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="-1" DataSourceID="SqlDataSource1" GridLines="Both" AllowMultiRowSelection="true" GroupPanelPosition="Top" AllowFilteringByColumn="True" AllowPaging="True" Font-Size="XX-Small" PageSize="5">
<GroupingSettings CollapseAllTooltip="Collapse all groups"></GroupingSettings>
<ClientSettings>
<Selecting AllowRowSelect="True" />
<Resizing AllowColumnResize="True" AllowResizeToFit="True" />
</ClientSettings>
<AlternatingItemStyle Font-Size="Small" />
<MasterTableView AutoGenerateColumns="False" DataKeyNames="IDENT_ASOC" DataSourceID="SqlDataSource1">
<Columns>
<telerik:GridClientSelectColumn UniqueName="Seleccionar">
</telerik:GridClientSelectColumn>
<telerik:GridBoundColumn DataField="IDENT_ASOC" HeaderText="ID CLIENTE" ReadOnly="True" SortExpression="IDENT_ASOC" UniqueName="IDENT_ASOC" AllowFiltering="False" AllowSorting="False">
<HeaderStyle Width="100px" />
<ItemStyle Width="100px"/>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="NOM_ASOC" FilterControlAltText="Filter NOM_ASOC column" HeaderText="CLIENTE" SortExpression="NOM_ASOC" UniqueName="NOM_ASOC">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
<ItemStyle Font-Size="Small" />
</telerik:RadGrid>
This can be done with some custom client-side logic. For example:
ASPX:
<
form
id
=
"form1"
runat
=
"server"
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
></
telerik:RadScriptManager
>
<
script
>
function OnCommand(sender, args) {
if (args.get_commandName() == "Page") {
var selectedItems = sender.get_masterTableView().get_selectedItems();
var selectedIndexes = "";
for (var i = 0; i <
selectedItems.length
; i++) {
var
delimiter
=
"|"
;
if (i + 1 == selectedItems.length) {
delimiter
=
""
;
}
selectedIndexes += selectedItems[i]._itemIndex + delimiter;
}
$get("<%=hf1.ClientID%>").value = selectedIndexes;
}
}
function OnMasterTableViewCreated(sender, args) {
if ($get("<%=hf1.ClientID%>").value != "") {
var selectedIndexes = $get("<%=hf1.ClientID%>").value.split('|');
for (var i = 0; i <
selectedIndexes.length
; i++) {
sender.get_masterTableView().get_dataItems()[selectedIndexes[i]].set_selected();
}
}
}
</script>
<
telerik:RadButton
ID
=
"RadButton1"
runat
=
"server"
/>
<
asp:HiddenField
ID
=
"hf1"
runat
=
"server"
/>
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
CellSpacing
=
"-1"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
GridLines
=
"Both"
AllowMultiRowSelection
=
"true"
GroupPanelPosition
=
"Top"
AllowFilteringByColumn
=
"True"
AllowPaging
=
"True"
Font-Size
=
"XX-Small"
PageSize
=
"5"
>
<
ClientSettings
>
<
ClientEvents
OnCommand
=
"OnCommand"
OnMasterTableViewCreated
=
"OnMasterTableViewCreated"
/>
</
ClientSettings
>
<
GroupingSettings
CollapseAllTooltip
=
"Collapse all groups"
></
GroupingSettings
>
<
ClientSettings
>
<
Selecting
AllowRowSelect
=
"True"
/>
<
Resizing
AllowColumnResize
=
"True"
AllowResizeToFit
=
"True"
/>
</
ClientSettings
>
<
AlternatingItemStyle
Font-Size
=
"Small"
/>
<
MasterTableView
AutoGenerateColumns
=
"False"
DataKeyNames
=
"IDENT_ASOC"
>
<
Columns
>
<
telerik:GridClientSelectColumn
UniqueName
=
"Seleccionar"
>
</
telerik:GridClientSelectColumn
>
<
telerik:GridBoundColumn
DataField
=
"IDENT_ASOC"
HeaderText
=
"ID CLIENTE"
ReadOnly
=
"True"
SortExpression
=
"IDENT_ASOC"
UniqueName
=
"IDENT_ASOC"
AllowFiltering
=
"False"
AllowSorting
=
"False"
>
<
HeaderStyle
Width
=
"100px"
/>
<
ItemStyle
Width
=
"100px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"NOM_ASOC"
FilterControlAltText
=
"Filter NOM_ASOC column"
HeaderText
=
"CLIENTE"
SortExpression
=
"NOM_ASOC"
UniqueName
=
"NOM_ASOC"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
<
ItemStyle
Font-Size
=
"Small"
/>
</
telerik:RadGrid
>
</
form
>
C#:
protected
DataTable GetData()
{
DataTable dt =
new
DataTable();
dt.Columns.Add(
"IDENT_ASOC"
,
typeof
(Int32));
dt.Columns.Add(
"NOM_ASOC"
,
typeof
(Int32));
dt.Columns.Add(
"Month"
,
typeof
(DateTime));
dt.Rows.Add(22, 1,
new
DateTime(DateTime.Now.Year, 1, 1));
dt.Rows.Add(0, 3,
new
DateTime(DateTime.Now.Year, 2, 1));
dt.Rows.Add(2, 4,
new
DateTime(DateTime.Now.Year, 3, 1));
dt.Rows.Add(5, 0,
new
DateTime(DateTime.Now.Year, 4, 1));
dt.Rows.Add(10, 0,
new
DateTime(DateTime.Now.Year, 5, 1));
dt.Rows.Add(3, 6,
new
DateTime(DateTime.Now.Year, 5, 1));
dt.Rows.Add(4, 9,
new
DateTime(DateTime.Now.Year, 5, 1));
dt.Rows.Add(11, 15,
new
DateTime(DateTime.Now.Year, 5, 1));
dt.Rows.Add(12, 21,
new
DateTime(DateTime.Now.Year, 5, 1));
return
dt;
}
protected
void
RadGrid1_NeedDataSource(
object
sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
(sender
as
RadGrid).DataSource = GetData();
}
In future when you have questions about different products I would like to ask you to open separate forum threads/ support tickets and choose the corresponding product type. Thus we can keep the threads clean and tidy.
Regards,
Danail Vasilev
Telerik