I can do dynamic server-side column groupings ONCE, but then can't get the grid to 're-set' for different groupings unless I change the AutoGenerateColumns to FALSE & generate the columns on the server-side.
The SECOND time (when a new Start Date is selected), I get the error: "No column group with the specified group name ( Mon_06-23 ) exists!"
(where Mon_06-23 is an 'old' grouping from the previous viewing)
Apparently I am not doing enough to "clear out the grid" before re-generating it with new Column Groupings.
My grid HTML is:
<telerik:RadGrid ID="RadGridWkSched" runat="server" CellSpacing="0" GridLines="Vertical" AutoGenerateColumns="True"
OnItemDataBound="RadGridWkSched_ItemDataBound" OnColumnCreated="RadGridWkSched_ColumnCreated">
</telerik:RadGrid>
My Server-side code is:
private void FillScheduleWeekGrid()
{
// get the Start date from the input control
DateTime dtstart = DateTime.Parse(RadDatePickerWeek.SelectedDate.ToString());
// clear out the grid before re-populating it
currentSection = "";
RadGridWkSched.Columns.Clear();
RadGridWkSched.MasterTableView.ColumnGroups.Clear();
for (int i = 0; i < 7; i++)
{
DateTime thisdt = dtstart.AddDays((double)i);
string weekDate = thisdt.ToString(ScheduleController.DateFormat);
// declare a column group for this date
GridColumnGroup colGroupDate = new GridColumnGroup();
RadGridWkSched.MasterTableView.ColumnGroups.Add(colGroupDate); // need to add it before setting the values
colGroupDate.Name = colGroupDate.HeaderText = weekDate;
colGroupDate.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
}
RadGridWkSched.DataSource = scheduleController.FillScheduleWeekDT(dtstart, serviceLevelID, Session["version"].ToString());
RadGridWkSched.DataBind();
}
}
The SECOND time (when a new Start Date is selected), I get the error: "No column group with the specified group name ( Mon_06-23 ) exists!"
(where Mon_06-23 is an 'old' grouping from the previous viewing)
Apparently I am not doing enough to "clear out the grid" before re-generating it with new Column Groupings.
My grid HTML is:
<telerik:RadGrid ID="RadGridWkSched" runat="server" CellSpacing="0" GridLines="Vertical" AutoGenerateColumns="True"
OnItemDataBound="RadGridWkSched_ItemDataBound" OnColumnCreated="RadGridWkSched_ColumnCreated">
</telerik:RadGrid>
My Server-side code is:
private void FillScheduleWeekGrid()
{
// get the Start date from the input control
DateTime dtstart = DateTime.Parse(RadDatePickerWeek.SelectedDate.ToString());
// clear out the grid before re-populating it
currentSection = "";
RadGridWkSched.Columns.Clear();
RadGridWkSched.MasterTableView.ColumnGroups.Clear();
for (int i = 0; i < 7; i++)
{
DateTime thisdt = dtstart.AddDays((double)i);
string weekDate = thisdt.ToString(ScheduleController.DateFormat);
// declare a column group for this date
GridColumnGroup colGroupDate = new GridColumnGroup();
RadGridWkSched.MasterTableView.ColumnGroups.Add(colGroupDate); // need to add it before setting the values
colGroupDate.Name = colGroupDate.HeaderText = weekDate;
colGroupDate.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
}
RadGridWkSched.DataSource = scheduleController.FillScheduleWeekDT(dtstart, serviceLevelID, Session["version"].ToString());
RadGridWkSched.DataBind();
}
}
