I have a dynamically generated grid where the first 4 rows are basically headers. "Project Name", "Customer Name", "division Name", "Sector Name"
For each project we have 2 columns. "Plan" and "Assign".
The 4 headers I listed should span the plan and assign columns. See the attached screen shot "Report Before Scrolling (everything looks good).png" to see what the desired output should be.
I used this thread as a starting point on how to make text in one row span 2 columns for a dynamically generated grid:
http://www.telerik.com/support/code-library/span-cells-in-grid-over-multiple-positions
My guess is that the part where you try to track the previousIndex compared to the current index is where I have issues.
When the report is first rendered to the screen it looks correct. Once you use the horizontal scroll the colspan values for the columns start to change. To see the HTML example of this I've included 2 screen shots. One called "HTML Before Scrolling - Colspan values look correct.png" and one called "HTML after scrolling -Colspan values have changed.png".
Here is the OnPreRender code where I set the colspan and very feebly attempt to manage the indeces of the items (read help!):
protected void radGrid1_OnPreRender(object sender, EventArgs e)
{
var headerRows = HeaderRows;
if (headerRows == null) return;
foreach (var row in headerRows)
{
var currentProjectID = row["projectID"].ToString();
var currentPlanColumnName = "Plan" + "_" + currentProjectID;
var currentAssignColumnName = "Assign" + "_" + currentProjectID;
foreach (GridDataItem dataItem in radGrid1.MasterTableView.Items)
{
dataItem[currentPlanColumnName].ColumnSpan = 2;
dataItem[currentAssignColumnName].Visible = false;
int previousItemIndex = dataItem.ItemIndex - 1;
if (previousItemIndex >= 0)
{
if (dataItem["Employees"].Text == dataItem.OwnerTableView.Items[previousItemIndex]["Employees"].Text)
{
dataItem.OwnerTableView.Items[previousItemIndex]["Employees"].RowSpan = 2;
dataItem["Employees"].Visible = false;
}
}
}
}
}
As I stated above the code in the OnPreRender where it compares the dataItem text to the previousItemIndex's text is where I'm probably causing the issue??
Any help is greatly appreciated.
Thank you :)