| protected void RadGrid_ItemDataBound(object sender, GridItemEventArgs newGridDataItem) |
| { |
| try |
| { |
| RadGrid radGrid = (RadGrid)sender; |
|
| #region Create Custom Header |
| |
| if (newGridDataItem.Item.ItemType == GridItemType.Header) |
| { |
| #region Create links to charts |
| |
| ... |
| // Box a the ItemType as it is easier to use |
| GridHeaderItem gridHeaderItem = (GridHeaderItem)newGridDataItem.Item; |
| |
| // Iterate thorugh every column and format the value |
| foreach (GridColumn gridColumn in radGrid.MasterTableView.RenderColumns) |
| { |
| if (gridColumn.ColumnType != "GridExpandColumn" && gridColumn.ColumnType != "GridRowIndicatorColumn") |
| { |
| ... |
| try |
| { |
| // Create a LinkButton control instead of setting the columns' .text property or the javascript will not work |
| LinkButton linkButton = (LinkButton)gridHeaderItem[gridColumn.UniqueName].Controls[0]; |
| linkButton.Text = gridColumn.UniqueName; |
| |
| // Create a hyperLink control for the chart to work and does not interfere with the sort LinkButton |
| if (_report.Grids[radGrid.ID][gridColumn.UniqueName].ChartColumnLink == true) |
| { |
| String chartParameters = String.Format(" <a alt=\"Click to view chart\" href=\"javascript:ViewChart('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}');\"><img border=\"0\" src=\"images/iconChart.gif\"></a>", _report.ManagerUserID.ToString(), _report.DepartmentID, Convert.ToByte(_report.DepartmentDrillDown), _report.Location, Convert.ToByte(_report.ShiftWindow), _report.StartDate.ToShortDateString(), _report.EndDate.ToShortDateString(), _report.ReportType, _report.AggregationPeriod, gridColumn.UniqueName); |
| |
| HyperLink chartHyperLink = new HyperLink(); |
| chartHyperLink.Text = chartParameters; |
| gridHeaderItem[gridColumn.UniqueName].Controls.Add(chartHyperLink); |
| } |
| } |
| catch |
| { |
| // If this fails, allow the column name to go w/o the chart link by default |
| } |
| } |
| } |
| } |
|
| #endregion Create links to charts |
| } |
|
| #endregion Create Custom Header |
| |
| ... // Create Custom Footer ommitted for easier troubleshooting |
| |
| #region Put the proper formatting on values before display |
| |
| if ((newGridDataItem.Item is GridDataItem) == true) |
| { |
| ... |
| GridDataItem gridDataItem = (GridDataItem)newGridDataItem.Item; |
| |
| // Iterate thorugh every column and format the value |
| foreach (GridColumn gridColumn in radGrid.MasterTableView.RenderColumns) |
| { |
| if (_report.Grids[radGrid.ID].ContainsKey(gridColumn.UniqueName) == true) |
| { |
| // Create the grid data item text in a control or .text property |
| Label textLabel = new Label(); |
| if (gridDataItem[gridColumn.UniqueName].Text == "NaN") |
| { |
| // Weird: Add both text and a control. If there are more controls added below, the text is hidden but, if there are no other controls, the text will show. |
| textLabel.Text = RadGrid_FormatText(radGrid, gridColumn.UniqueName, "0"); |
| gridDataItem[gridColumn.UniqueName].Text = RadGrid_FormatText(radGrid, gridColumn.UniqueName, "0"); |
| } |
| else |
| { |
| // Do not display items that are special case exceptions governed by the .ReplaceHierarchyParentText property from xml |
| if (String.IsNullOrEmpty(_report.Grids[radGrid.ID][gridColumn.UniqueName].ReplaceHierarchyParentText) == false && gridDataItem.OwnerTableView.ParentItem == null) |
| { |
| textLabel.Text = _report.Grids[radGrid.ID][gridColumn.UniqueName].ReplaceHierarchyParentText; |
| gridDataItem[gridColumn.UniqueName].Text = _report.Grids[radGrid.ID][gridColumn.UniqueName].ReplaceHierarchyParentText; |
| } |
| else |
| { |
| // Weird: Add both text and a control. If there are more controls added below, the text is hidden but, if there are no other controls, the text will show. |
| textLabel.Text = RadGrid_FormatText(radGrid, gridColumn.UniqueName, gridDataItem[gridColumn.UniqueName].Text); |
| gridDataItem[gridColumn.UniqueName].Text = RadGrid_FormatText(radGrid, gridColumn.UniqueName, gridDataItem[gridColumn.UniqueName].Text); |
| } |
| } |
| |
| gridDataItem[gridColumn.UniqueName].Controls.Add(textLabel); |
|
| #region Create a hyperLink control for the chart to work and does not interfere with the sort |
| |
| // Create a hyperLink control for the chart to work and does not interfere with the sort LinkButton |
| if (_report.Grids[radGrid.ID][gridColumn.UniqueName].ChartRowLink == true) |
| { |
| String chartParameters = String.Format(" <a alt=\"Click to view chart\" href=\"javascript:ViewChart('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}');\"><img border=\"0\" src=\"images/iconChart.gif\"></a>", gridDataItem[_childRadGridProperties["MasterTableView.DataKeyNames"]].Text, _report.DepartmentID, Convert.ToByte(_report.DepartmentDrillDown), _report.Location, Convert.ToByte(_report.ShiftWindow), _report.StartDate.ToShortDateString(), _report.EndDate.ToShortDateString(), _report.ReportType, _report.AggregationPeriod, gridColumn.UniqueName); |
| |
| HyperLink chartHyperLink = new HyperLink(); |
| chartHyperLink.Text = chartParameters; |
| |
| gridDataItem[gridColumn.UniqueName].Controls.Add(chartHyperLink); |
| } |
|
| #endregion Create a hyperLink control for the chart to work and does not interfere with the sort |
| } |
| } |
| } |
|
| #endregion Put the proper formatting on values before display |
| } |
| catch (Exception exception) |
| { |
| //UNDONE: Wireup error handler object |
| Console.Write("error"); |
| } |
| } |