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

[Solved] RadGrid Detail table not remembering its state

1 Answer 136 Views
Grid
This is a migrated thread and some comments may be shown as answers.
aditi
Top achievements
Rank 1
aditi asked on 16 Jan 2010, 02:51 AM

Hi,

I am having a radgrid(with detailtables) and a radcombobox with checkboxes in it. Initially on pageload, all the items in the radcombobox are clicked and the detail table shows all the columns in it. When the user unselects any of the item in the combo box, the column in the detail table should become invisible. 

 <telerik:RadComboBox ID="RadComboBox1" runat="server"  HighlightTemplatedItems="true" EmptyMessage="select display columns"
                    Skin="Office2007" AllowCustomText="true" Width="240px">
                    <ItemTemplate>
                        <asp:CheckBox runat="server" ID="chk1" Checked="true" OnCheckedChanged="chk1_CheckedChanged" AutoPostBack="true"/>
                        <asp:Label runat="server" ID="Label1" Text='<%# Eval("menuitem_gridname") %>' AssociatedControlID="chk1">
                        </asp:Label>
                    </ItemTemplate>
                </telerik:RadComboBox>

codebehind

 

 

 

 

protected void chk1_CheckedChanged(object sender, EventArgs e)  
{
string str = ""; 
for (int i = 0; i < RadComboBox1.Items.Count; i++) 
{
CheckBox chk = (CheckBox)RadComboBox1.Items[i].FindControl("chk1"); 
if (chk.Checked == false) {
str = str + "," + RadComboBox1.Items[i].Value;  
}
}
RadGrid2.Rebind();

}

 

 protected void RadGrid2_DetailTableDataBind(object source, GridDetailTableDataBindEventArgs e)
        {

            //string str = Request.QueryString["Cols"].ToString();
            string str = "";
            for (int i = 0; i <  RadComboBox1.Items.Count;i++) 
            {
                CheckBox chk = (CheckBox)RadComboBox1.Items[i].FindControl("chk1");                
                if (chk.Checked == false)
                {
                    str = str + "," + RadComboBox1.Items[i].Value;
                }
            }
            e.DetailTableView.DataSource = dsSwitch.Tables[1];
          
            //string str = Request.QueryString["Cols"].ToString();

            string[] cols = str.Split(',');
            for (int i = 0; i < cols.Length; i++)
            {
                if (cols[i].ToString().Equals(string.Empty))
                    continue;
                int j = int.Parse(cols[i].ToString());
                e.DetailTableView.Columns[j].Visible = false;
            }
            //e.DetailTableView.Columns[3].Visible = false;
        }

Now the problem is it is not remembering the state of the radgrid. For example, If we expand a particular row in the mastergrid and unselect an item in the combobox, none of the rows are in expanded state. It is not remember the state of the radgrid.
How to remeber the state of the grid on selecting and unselectiong the items in a combobox to hide the columns of a detail table in an ajax way?

Thank you.

 

 

 

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 18 Jan 2010, 10:49 AM
Hello Aditi,

You can go through he following link which explains on how to retain the expanded/selected state for grid items in hierarchy upon a rebind command.
Retain expanded/selected state in hierarchy on rebind

Thanks
Princy.
Tags
Grid
Asked by
aditi
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or