This is a migrated thread and some comments may be shown as answers.

[Solved] Scrolling radbox clears selection

1 Answer 73 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Fabio
Top achievements
Rank 1
Fabio asked on 23 Jun 2009, 03:36 PM
Hi, I have a strange behaviour in a scrolled radgrid, using server-side selection.

Markup:
<telerik:RadGrid ID="rgCT" runat="server" Width="345" OnNeedDataSource="rgCT_NeedDataSource" 
                             AutoGenerateColumns="false" EnableAjaxSkinRendering="true" AllowMultiRowSelection="true"
                <PagerStyle Mode="NextPrevAndNumeric" /> 
                <SelectedItemStyle BackColor="Gray" ForeColor="White" /> 
                <EditItemStyle BackColor="#F7BD02" ForeColor="Black" /> 
                <MasterTableView TableLayout="Fixed" CommandItemDisplay="None" DataKeyNames="CT_ID"
                    <Columns> 
                        <telerik:GridTemplateColumn UniqueName="Selection" HeaderStyle-Width="10%"
                            <ItemTemplate> 
                                <asp:CheckBox ID="CheckBox1" OnCheckedChanged="ToggleRowSelection" AutoPostBack="True" 
                                    runat="server"></asp:CheckBox> 
                            </ItemTemplate> 
                        </telerik:GridTemplateColumn> 
                        <telerik:GridBoundColumn UniqueName="CT_ID" DataField="CT_ID" Visible="false" /> 
                        <telerik:GridBoundColumn UniqueName="CT_NAME" DataField="CT_NAME" HeaderText="CT" HeaderStyle-Width="89%"/> 
                    </Columns> 
                </MasterTableView> 
                <ClientSettings> 
                    <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True" 
                               ScrollHeight="200px"  /> 
                </ClientSettings> 
            </telerik:RadGrid> 

Code-behind:
        protected void ToggleRowSelection(object sender, EventArgs e) 
        { 
            ((sender as CheckBox).Parent.Parent as GridItem).Selected = (sender as CheckBox).Checked; 
        } 

When I touch the vertical scrollbar (even if I don't really "scroll") the selection get cleared.
I see this in the onclick of a button, checking the SelectedIndexes.Count property of the Grid.
When I don't touch the scrollbar all selections are preserved, when I touch it the SelectedIndexes.Count is 0.

Any clue?

Thanks in advance for your help.






1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 24 Jun 2009, 05:26 AM
Hi Fabio,

I also had a similar problem.  But in my case the the CheckBox remains checked even though the Grid row selection is gone. I have given a work around for this in the following forum post. You may go through it and see if it helps.
Major Problem: Grid loses SelectedItems on Client Scroll

Shinu
Tags
Grid
Asked by
Fabio
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or