Inheriting RadGrid
You can inherit RadGrid to create a custom grid control and inherit GridTableView to customize the table views used by that control. The examples in this article use ASP.NET Web Forms markup and code-behind.
Register the custom grid control
Assume that the custom grid is named InheritedGrid, is compiled into InheritedGrid.dll, and uses the myRadG tag prefix. Add the TagPrefix attribute to the application assembly, for example in AssemblyInfo.cs:
using System.Web.UI;
[assembly: TagPrefix("MyBaseNamespace.MyControls", "myRadG")]
Register both the Telerik and custom assemblies on the ASPX page:
<%@ Register TagPrefix="radG" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register TagPrefix="myRadG" Namespace="MyBaseNamespace.MyControls" Assembly="InheritedGrid" %>
Use the custom prefix for the inherited grid and the Telerik prefix for the standard grid table and column classes:
<myRadG:InheritedGrid ID="InheritedGrid1" runat="server">
<MasterTableView>
<Columns>
<radG:GridBoundColumn DataField="CustomerID" HeaderText="Customer ID" />
</Columns>
<DetailTables>
<radG:GridTableView Name="Orders" />
</DetailTables>
</MasterTableView>
</myRadG:InheritedGrid>
This registration enables Visual Studio to recognize the tag prefixes and allows the RadGrid Property Builder to serialize the design-time markup correctly.
Inherit GridTableView
To use a custom table view in the hierarchy, register the custom namespace and declare the custom table view in the DetailTables collection:
<%@ Register Namespace="MyNamespace" TagPrefix="my" %>
<my:MyGrid ID="MyGrid1" runat="server" OnNeedDataSource="MyGrid1_NeedDataSource">
<MasterTableView>
<DetailTables>
<my:MyGridTableView />
</DetailTables>
</MasterTableView>
</my:MyGrid>Override the CreateTableView() method in the custom RadGrid class and return an instance of the custom GridTableView implementation.
Support limitation
This article provides basic instructions for inheriting
RadGridandGridTableView. Telerik does not support issues specific to custom inherited implementations.