Creating custom rows
RadGridView provides a variety of visual cells per row with different functionality and purpose. However, in some cases you may need to display custom elements, not a single cell per column. This article demonstrates a sample approach how to create a custom row element.
Custom new row
Consider the RadGridView is populated with data form Northwind.Products table.
In order to enlarge the new row's height, you can set the TableElement.ViewInfo.TableAddNewRow. Height property.
On the new row we will display a RadChartViewElement visualizing the Products data. For this purpose we should follow the steps below:
You can replace the RadChartViewElement with any RadElement or a set of elements.
Figure 1: The new row is replaced with the custom one
1. Create a descendant of the GridRowElement and override its CreateChildElements where you should add a single GridCellElement that contains the chart. The IsCompatible method determines for which GridViewRowInfo the custom row element is applicable:
2. Create a descendant of the GridViewNewRowInfo and specify that it uses the row element from the previous step by overriding its RowElementType property.
3. The last step is to subscribe to the CreateRowInfo event and replace the default GridViewNewRowInfo with your custom one.
You should subscribe to the CreateRowInfo event at design time in order to ensure that the event will be fired when a data row have to be created.