Hi.
My requirement is for a grid that will be dynamically populated,
Because of this I build the entire grid in my code behind.
I have this 99% working except for this issue with grouping:
When I group by a column and expand the group, then collapse the same group again it will collapse without any problem.
I also have these tabs which is essentially just a string value that I pass in from a hidden field it can optionally be used as a filter when I bring back a search result that will populate my grid.
The problem come in when I pass in this string; I am able to expand any of my groups, but when I want to collapse the group the page posts back but does not collapse the group again.
On page Page_Init I use DefineGridStructure(); to build my grid and bind the datatable that comes from ed.SearcheDOCS(selectedTab, selectedVerticalTab, selectedVerticalTabIndex);
Then depending on the number of columns returned I build the grid,
when one of these filter values I mentioned above is passed in while grouped I use the code below, so when it posts back to collapse after having been expanded the code runs as expected but will not collapse the expanded group.
My requirement is for a grid that will be dynamically populated,
Because of this I build the entire grid in my code behind.
I have this 99% working except for this issue with grouping:
When I group by a column and expand the group, then collapse the same group again it will collapse without any problem.
I also have these tabs which is essentially just a string value that I pass in from a hidden field it can optionally be used as a filter when I bring back a search result that will populate my grid.
The problem come in when I pass in this string; I am able to expand any of my groups, but when I want to collapse the group the page posts back but does not collapse the group again.
protected void Page_Init(object sender, System.EventArgs e)
{
string filterValue = HorizontalTabFilter();
string verticalFilterValue = VerticalTabFIlter();
DefineGridStructure();
}
private void DefineGridStructure()
{
string searchColumns = gf.GetConfigValue(HttpContext.Current.Session["APPLICATION"].ToString(), "SEARCHCOLUMNS");
List<
string
> searchColumnList = searchColumns.Split('|').ToList();
RadGrid grid = new RadGrid();
grid.ID = "RadGrid1";
grid.AllowSorting = true;
grid.GroupingEnabled = true;
grid.ClientSettings.AllowGroupExpandCollapse = true;
grid.ClientSettings.AllowDragToGroup = true;
grid.ClientSettings.Scrolling.AllowScroll = true;
grid.ClientSettings.Scrolling.UseStaticHeaders = true;
grid.ClientSettings.Scrolling.SaveScrollPosition = true;
grid.ClientSettings.Scrolling.EnableVirtualScrollPaging = true;
grid.ClientSettings.Resizing.ResizeGridOnColumnResize = true;
grid.ClientSettings.Resizing.AllowColumnResize = true;
grid.ClientSettings.Resizing.EnableRealTimeResize = true;
grid.ClientSettings.Resizing.ResizeGridOnColumnResize = true;
grid.ClientSettings.Resizing .AllowResizeToFit = true;
grid.HorizontalAlign = HorizontalAlign.Left;
grid.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
grid.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
grid.AlternatingItemStyle.HorizontalAlign = HorizontalAlign.Left;
grid.EnableViewState = true;
if (selectedTab != "" || selectedVerticalTab != "")
{
grid.DataSource = null;
grid.Rebind();
}
grid.DataSource = dt = ed.SearcheDOCS(selectedTab, selectedVerticalTab, selectedVerticalTabIndex);
colCount = dt.Columns.Count;
rowCount = dt.Rows.Count;
grid.Width = Unit.Percentage(99);
grid.Height = Unit.Percentage(99);
grid.PageSize = Convert.ToInt32(gf.GetConfigValue(HttpContext.Current.Session["APPLICATION"].ToString(), "PAGINATION"));
if (Convert.ToInt32(gf.GetConfigValue(HttpContext.Current.Session["APPLICATION"].ToString(), "PAGINATIONALLOWED")) == 1)
{
grid.AllowPaging = true;
}
else
{
grid.AllowPaging = false;
}
grid.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric;
grid.AutoGenerateColumns = false;
grid.ShowGroupPanel = true;
grid.HeaderStyle.CssClass = "HEADER";
grid.MasterTableView.Width = Unit.Percentage(100);
grid.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
grid.MasterTableView.DataKeyNames = new string[] { "DOCNUM" };
GridBoundColumn boundColumn = new GridBoundColumn();
GridImageColumn gi;
GridButtonColumn gb;
GridHyperLinkColumn hyperlinkColumn;
boundColumn = new GridBoundColumn();
gi = new GridImageColumn();
gb = new GridButtonColumn();
hyperlinkColumn = new GridHyperLinkColumn();
grid.MasterTableView.TableLayout = GridTableLayout.Fixed;
grid.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
GridTableView tableViewOrders = new GridTableView(grid);
grid.MasterTableView.Columns.Add(boundColumn);
if (colCount == 10)
{
boundColumn.DataField = "icon";
boundColumn.HeaderText = "icon";
boundColumn.Visible = false;
boundColumn.FilterImageUrl = "icon_icon.gif";
string[] fld0 = { "icon" };
gi = new GridImageColumn();
gi.DataImageUrlFields = fld0;
gi.DataImageUrlFormatString = "~/images/{0}";
gi.HeaderText = "";
gi.HeaderStyle.Width = Unit.Pixel(30);
gi.ImageHeight = Unit.Pixel(20);
gi.ImageWidth = Unit.Pixel(20);
grid.MasterTableView.Columns.Add(gi);
grid.MasterTableView.GroupsDefaultExpanded = false;
GridGroupByExpression expression = new GridGroupByExpression();
GridGroupByField gridGroupByField = new GridGroupByField();
gridGroupByField = new GridGroupByField();
gridGroupByField.FieldName = "AUTHOR";
gridGroupByField.HeaderText = "AUTHOR";
expression.SelectFields.Add(gridGroupByField);
gridGroupByField = new GridGroupByField();
gridGroupByField.FieldName = "AUTHOR";
gridGroupByField.HeaderText = "AUTHOR";
expression.GroupByFields.Add(gridGroupByField);
boundColumn = new GridBoundColumn();
grid.MasterTableView.Columns.Add(boundColumn);
boundColumn.DataField = "application";
boundColumn.HeaderText = searchColumnList[0].ToString();
boundColumn.Visible = false;
boundColumn = new GridBoundColumn();
grid.MasterTableView.Columns.Add(boundColumn);
boundColumn.DataField = searchColumnList[1].ToString();
//boundColumn.ItemStyle.Width = Unit.Pixel(70);
boundColumn.HeaderStyle.Width = Unit.Pixel(70);
boundColumn.HeaderText = gf.GetHeadingText(searchColumnList[1].ToString());
string[] fld = { "link" };
hyperlinkColumn.DataNavigateUrlFields = fld;
hyperlinkColumn.ItemStyle.CssClass = "hyperlink";
hyperlinkColumn.DataNavigateUrlFormatString = "{0}";
hyperlinkColumn.HeaderText = gf.GetHeadingText(searchColumnList[2].ToString());
hyperlinkColumn.ItemStyle.Width = Unit.Pixel(300);
hyperlinkColumn.HeaderStyle.Width = Unit.Pixel(300);
hyperlinkColumn.DataTextField = "DOCNAME";
hyperlinkColumn.AllowSorting = true;
hyperlinkColumn.ItemStyle.Wrap = false;
grid.MasterTableView.Columns.Add(hyperlinkColumn);
hyperlinkColumn = new GridHyperLinkColumn();
string[] fld4 = { "ABSTRACTLINK" };
hyperlinkColumn.DataNavigateUrlFields = fld4;
hyperlinkColumn.ItemStyle.CssClass = "hyperlink";
hyperlinkColumn.DataNavigateUrlFormatString = "{0}";
hyperlinkColumn.HeaderText = "Comments";
hyperlinkColumn.HeaderStyle.Width = Unit.Pixel(75);
hyperlinkColumn.ItemStyle.Width = Unit.Pixel(75);
hyperlinkColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
hyperlinkColumn.DataTextField = "ABSTRACT";
hyperlinkColumn.AllowSorting = true;
hyperlinkColumn.ItemStyle.Wrap = false;
grid.MasterTableView.Columns.Add(hyperlinkColumn);
hyperlinkColumn = new GridHyperLinkColumn();
string[] fld2 = { "editlink" };
hyperlinkColumn.DataNavigateUrlFields = fld2;
if (gf.GetConfigValue(HttpContext.Current.Session["APPLICATION"].ToString(), "ALLOWEDIT") == "0")
{
hyperlinkColumn.Visible = false;
}
hyperlinkColumn.DataNavigateUrlFormatString = "{0}";
hyperlinkColumn.HeaderText = "Edit";
hyperlinkColumn.HeaderStyle.Width = Unit.Pixel(45);
hyperlinkColumn.ItemStyle.Width = Unit.Pixel(45);
hyperlinkColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
hyperlinkColumn.DataTextField = "editlink";
hyperlinkColumn.ImageUrl = "~/images/EditProfile2.png";
grid.MasterTableView.Columns.Add(hyperlinkColumn);
hyperlinkColumn = new GridHyperLinkColumn();
string[] fld3 = { "versionLink" };
hyperlinkColumn.DataNavigateUrlFields = fld3;
if (gf.GetConfigValue(HttpContext.Current.Session["APPLICATION"].ToString(), "ALLOWVERSION") == "0")
{
hyperlinkColumn.Visible = false;
}
hyperlinkColumn.DataNavigateUrlFormatString = "{0}";
hyperlinkColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
hyperlinkColumn.HeaderStyle.Width = Unit.Pixel(55);
hyperlinkColumn.ItemStyle.Width = Unit.Pixel(55);
hyperlinkColumn.HeaderText = "Version";
hyperlinkColumn.DataTextField = "versionLink";
hyperlinkColumn.ImageUrl = "~/images/NewVersion2.png";
grid.MasterTableView.Columns.Add(hyperlinkColumn);
boundColumn = new GridBoundColumn();
grid.MasterTableView.Columns.Add(boundColumn);
boundColumn.DataField = "link";
boundColumn.HeaderText = "Link";
boundColumn.Visible = false;
boundColumn = new GridBoundColumn();
grid.MasterTableView.Columns.Add(boundColumn);
boundColumn.DataField = "ABSTRACTLINK";
boundColumn.HeaderText = "ABSTRACTLINK";
boundColumn.Visible = false;
this.PlaceHolder1.Controls.Add(grid);
}
On page Page_Init I use DefineGridStructure(); to build my grid and bind the datatable that comes from ed.SearcheDOCS(selectedTab, selectedVerticalTab, selectedVerticalTabIndex);
Then depending on the number of columns returned I build the grid,
when one of these filter values I mentioned above is passed in while grouped I use the code below, so when it posts back to collapse after having been expanded the code runs as expected but will not collapse the expanded group.
if (selectedTab != "" || selectedVerticalTab != "")
{
grid.DataSource = null;
grid.Rebind();
} grid.DataSource = dt = ed.SearcheDOCS(selectedTab, selectedVerticalTab, selectedVerticalTabIndex);
I could really use some help with this.
Any ideas?