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.