I am using the following code to get the first column of the grid as a check box column .
<
telerik:radgrid
ID
=
"RadGrid2"
DataSourceID
=
"SqlDataSource1"
AllowMultiRowSelection
=
"true"
runat
=
"server"
AllowSorting
=
"True"
GridLines
=
"None"
onneeddatasource
=
"RadGrid2_NeedDataSource"
OnItemCreated
=
"RadGrid1_ItemCreated"
EnablePostBackOnRowClickproperty
=
"true"
OnItemCommand
=
"RadGrid1_ItemCommand"
>
<
MasterTableView
>
<
Columns
>
<
telerik:GridClientSelectColumn
UniqueName
=
"ClientSelectColumn"
/>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
EnableRowHoverStyle
=
"true"
>
<
Selecting
AllowRowSelect
=
"True"
/>
</
ClientSettings
>
</
telerik:radgrid
>
Here i need to do some logic like on clicking particular check box add one id field to viewstate/session.And remove that id on uncheck of that checkbox.
If i use GridClientSelectColumn , how can i handle the check box check changed event ?is there any grid events similar to this ?
I tried
EnablePostBackOnRowClickproperty
="True"
But then also postback is not happening on row click .
Any help is appreciated!!
Regards,
Soumya
11 Answers, 1 is accepted
server side selection : http://demos.telerik.com/aspnet-ajax/grid/examples/programming/selectrowwithcheckbox/defaultcs.aspx
let me know if any concern.
Thanks,
Jayesh Goyani
A better approach is to use a checkbox inside template column and handle the checkedChange event.
The following online demo describes the same.
Grid / Server-Side Row Selection.
Thanks,
Shinu.
I tried by placing the check box inside template column as shown in the http://demos.telerik.com/aspnet-ajax/grid/examples/programming/selectrowwithcheckbox/defaultcs.aspx.
But in my case the following case is not happining.
select header check box-> unselect a single check box -> the header check box also should get unchecked .
i added this code as well . but not working
<telerik:RadAjaxManager ID="RadAjaxManager1" EnableAJAX="true" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="myGrd">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="myGrd" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
try to set <asp:CheckBox CausesValidation="false"
Thanks,
Jayesh Goyani
Hi,
From http://demos.telerik.com/aspnet-ajax/grid/examples/programming/selectrowwithcheckbox/defaultcs.aspx.
I could find the following code block
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
GridHeaderItem headerItem = grdCurrent.MasterTableView.GetItems(GridItemType.Header)[0] as GridHeaderItem;
(headerItem.FindControl("headerChkbox") as CheckBox).Checked = grdCurrent.SelectedItems.Count == grdCurrent.Items.Count;
}
I changed the code behind also with the needed event handlers as given in the example.
Now I could see the result..ie on un checking a single check box causes the un checking of the header check box and visa versa.
But this won’t work when scroll is there on the grid.
When I clicked a check box it got selected, then again i select another check box in another row , the first one remain checked but the corresponding row is not getting selected. Only the last checked row gets selected .When I remove scroll this problem goes
why I want scroll: though I have pagination, certain columns are big descriptions. I have given column width in percentage in the radgrid .If the length of the column exceeds that limit, the grid will go beyond visibility .So scroll is given.
Thanks in advance.
What is the version of RadControls for ASP.NET AJAX you are using? Also, is this replicable, if you try to select two subsequent items without scrolling meanwhile?
All the best,
Iana Tsolova
the Telerik team
Hi Iana,
Thanks for your response.
With out scroll there is no problem.
Version: 2011.1 519
I got a response from service center that it is a problem with grid and they suggested a work around
<
Selecting
AllowRowSelect
=
"true"
/>
This is working fine with out update panel, but with update panel it behaves as previously.
Is there any work around for that?
(Update panel is used for triggering timer to execute a section code in fixed time interval)
Thanks ....
What I wanted to know was not if it works without scrolling enabled. But if it works with scrolling enabled and if you select subsequent items without scrolling in between.
Note that selected items are cleared for the grid after it is rebound. Thus if you page it is expected the already selected items to be lost. You can try persisting them as in the below articles:
http://www.telerik.com/help/aspnet-ajax/grid-persist-selected-rows-client-sorting-paging-grouping-filtering.html
http://www.telerik.com/help/aspnet-ajax/grid-persist-selected-rows-on-sorting.html
All the best,
Iana Tsolova
the Telerik team
Hi Iana ,
Thanks .This links are indeed helpful for me to retain the selected values while rebind.I had that requirement too.
But in this thread I described a different issue .
My REquirement is : select header check box-> unselect a single check box -> the header check box also should get unchecked
Bbut it was not happening and i added this logic in prerender .
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
GridHeaderItem headerItem = grdCurrent.MasterTableView.GetItems(GridItemType.Header)[0] as GridHeaderItem;
(headerItem.FindControl("headerChkbox") as CheckBox).Checked = grdCurrent.SelectedItems.Count == grdCurrent.Items.Count;
}
I have check box as first column and checking the check boxes make the corresponding rows selected .
If there is no scroll on the radgrid, i am able to check all the check boxes in a grid page and all of those rows are getting selected. .If scroll comes the grid, the selection of a single row will go if I select another row.
For this Telerik suppor team suggested to add the following
<Selecting
AllowRowSelect
=
"true"
/>
Now working with scrolling as well .But if Updatepanel is there the code piece added above is not having any effect.
How can we use it with Updatepanel?
Thanks ..
Can you open a formal support ticket and send me there the different version of your code so I can observe the behavior you are talking about?
Best wishes,
Iana Tsolova
the Telerik team
I already opend a formal ticket # 464267 .
Thanks .