RIA OLAP Grid: Customizing Cells' Content
Posted by - NA - on 02 December 2008 08:03 PM
|
|
This article discusses customizing Ria OLAP Grid contents. Read the article on the HTML OLAP Grid customization here. Formatting Cells in the Data Area Setting the cell appearance in the RIA controls is possible through writing the DrawCell event handler. This event is called upon filling the cellset for each cell of the Grid, and allows changing the font color, the text displayed in the cell, as well as specifying the method of background filling (either solid or set gradient). In this event handler, you can also assing any tooltip for the cell. Below we'll discuss a few examples of realizing this event handlers. Formatting Cells in the Data AreaObjective: to format the Grid cells contents: ![]() We need to format the cells in the "Sales Amount" measure as currency values, and "Order Count" as group-delimited integers, using German regional settings. To do that we'll use the following event handler: protected void RiaOLAPGrid1_DrawCell( object sender, DrawCellEventArgs e){ IDataCell dc = e.Cell as IDataCell; if ((dc != null ) && (dc.Data != null )) { if ((dc.Address.Measure != null ) && (dc.Address.Measure.DisplayName == "Sales Amount" )) { e.Text = Convert.ToDecimal(dc.Data).ToString( "c" , new CultureInfo( "de-DE" ).NumberFormat); } if ((dc.Address.Measure != null ) && (dc.Address.Measure.DisplayName == "Order Count" )) { e.Text = Convert.ToDecimal(dc.Data).ToString( "n0" , new CultureInfo( "de-DE" ).NumberFormat); } } } The Grid then will look like this: ![]() Conditional FillingObjective: to mark the data cells with values below 1,000,000: To do that, we’ll assign the gradient background filling of these cells. The following code will do: protected void RiaOLAPGrid1_DrawCell(object sender, DrawCellEventArgs e) The Grid then will look like this: ![]() Explore the CellObjective: to assign each data cell a tooltip, describing its position in the multi-dimensional Cube. To do that, we’ll apply to the appropriate fields and methods of the IDataCell.Address interface that represents the address of the specified cell. From here, we’ll get the string containing information about the determined levels and measures of the specified cell, and assign this string to the DrawCellEventArgs.Tooltip property. protected void RiaOLAPGrid1_DrawCell(object sender, DrawCellEventArgs e) Now, by moving the cursor over the data cell, we’ll get a picture like this: ![]() Placing images into cellsAim: to place images into cells to visualize data protected void RiaOLAPGrid1_DrawCell(object sender, DrawCellEventArgs e) As a result, the Grid should look like this: ![]() | |
|