
Hi dear telerikers!
I was just playing around with the new Prometheus Controls and would really like to inherit from RadGrid to extend it a little (for example i would rather open up the Editform as a RadWindow instead of using the built in custom editform)
I built a Server Control Library, added a reference to Telerik.Web.UI and also to System.Web.Extensions.
The custom control is defined as follows:
using
System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Softwaretailor.Web.UI.WebControls
{
public class CustomGrid : Telerik.Web.UI.RadGrid
{
}
}
Afterwards I added a Web Application and referenced the Server Control Project.
I modified the web.config file:
<
pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="telerik" namespace="Telerik.Web.UI" assembly="Telerik.Web.UI"/>
<add tagPrefix="swt" namespace="Softwaretailor.Web.UI.WebControls" assembly="Softwaretailor.Web.UI"/>
</controls>
</pages>
When I add
<
telerik:RadGrid ID="RadGrid1" runat="server"></telerik:RadGrid>
everything works as expected....
trying to use my custom control like
<
swt:CustomGrid ID="CustomGrid1" runat="server"></swt:CustomGrid>
I get a Visual Studio (2008) warning:
Warning 1 Generation of designer file failed: Unable to create type 'swt:CustomGrid'. Could not load file or assembly 'Telerik.Web.UI, Version=2007.3.1218.20, Culture=neutral, PublicKeyToken=121fae78165ba3d4' or one of its dependencies. The system cannot find the file specified. D:\My Documents\Visual Studio 2008\Projects\RMA Management\WebPlayground\Default.aspx 18 0 WebPlayground
The project compiles, but neither is the designer-file modified correctly, nor do i get intellisense support in the .aspx file....
I'm literally tearing my hair the last hour... can't figure out what I'm doing wrong...
Any help greatly appreciated!!
Kind regards,
Wolfgang
13 Answers, 1 is accepted

I started all over, set up a new solution and it worked...
Anyway... I'm curious...
Would it be possible to completely switch the MasterTableView with a custom MasterTableView which has a custom GridEditFormSettings Member to configure a WebForm as EditForm which would be displayed via a RadWindow?
Would be awesome, but i can't really persuade the Visual Studio Designer that the <MasterTableView> should not be of the type Telerik.Web.UI.GridTableView but rather something else...
Hints anyone? ;-)
This can probably be attained by inheriting the GridTableView class (the nested tables in hierarchy as well as the master table in the grid is of type GridTableView) and defining additional property which to specify pop-up edit type. Naturally, you will need to handle the custom edit form with your own code implementation.
Best regards,
Stephen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

Thanks for your reply! Unfortunately it doesn't seem to be that easy...
First step was to inherit my own CustomGridTableView and add a custom property:
public class CustomGridTableView : Telerik.Web.UI.GridTableView
{
public CustomGridTableView(Telerik.Web.UI.RadGrid ownerGrid) : base(ownerGrid) { }
[PersistenceMode(PersistenceMode.Attribute)]
public string CustomProperty
{
get;
set;
}
}
public override CustomGridTableView MasterTableView
Unfortunately this approach doesn't work, because I get the error-message that the MasterTableView must be of type "Telerik.Web.UI.GridTableView'.Nextbest thing would be to introduce my own MasterTableView with
public new CustomGridTableView MasterTableView
which is accepted by the compiler. When i try to use the CustomRadGrid on a aspx-site altough, I run into the real problem...<swt:CustomRadGrid ID="Grid" runat="server">
<MasterTableView>
</MasterTableView>
</swt:CustomRadGrid>
When I start up the site, I get the "Parser Error" exception at the '<MasterTableView>' line also inlcuding the errormessage 'Ambiguous match found'.
Would be really great if this could be solved....
My only other idea would be to use the Mediator design pattern to hook up the RadGrid with a RadWindowManager and let it to what has to be done ;-) But I really find the approach of inheriting from RadGrid and GridTableView a lot more apealing...
All the best,
Wolfgang
Please find attached a sample web application that demonstrates the needed approach. Let me know if you have other question and/or problems.
Kind regards,
Plamen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

Thanks
I updated the example submitted by my colleague Plamen to use the Prometheus version of RadGrid and ajaxified the control via RadAjaxManager. The same code implementation worked properly on my machine. Can you please verify that on your end? Let me know if I am missing something.
Best regards,
Stephen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

I also have another question in the project you sent me in the MyRadGrid.cs file you can find the following lines
public override GridTableView MasterTableView
{
get
{
return base.MasterTableView;
}
}
It seems to me that it is useless since it does not change the behavior right?
The second problem with this solution is that you can't set the MyProperty in the aspx files declaratively since the type of MasterTableView is not declared as MyGridTableView. I get this error in the designer
Error 32 Validation (ASP.Net): Attribute 'MyProperty' is not a valid attribute of element 'MasterTableView'. C:\Documents and Settings\evillemure\Desktop\Telerik\080209_CustomRadGrid\CustomRadGrid\WebSite\Default.aspx 31 88 C:\...\WebSite\
This is no more a problem for us because of the way we have decided to implement the functionnality.
Anyway this could be a feature request but it is not important enough for me to do feature request.
Thanks you for you help
Please find attached a small sample that shows how to create your own MasterTableView with intellisense.
Don't hesitate to contact us if you have any other questions.
Greetings,
Plamen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

I want to create a new RadGrid by inherithing standard RadGrid.
My purpouse is to create a general RadGrid structure that is used like starting point to create the singles different Radgrid's instances of my program.
For example I want that each of my RadGrid has a MasterTableView with a predefined CommandItemTemplate and some properties set to specific values. I try to do this by create a DLL that contain this code:
Imports Microsoft.VisualBasic |
Imports Telerik.Web.UI |
Imports System.Web.UI.WebControls |
Public Class RadGridM |
Inherits RadGrid |
Public Sub New() |
'common radgrid properties |
Me.AllowPaging = True |
Me.AllowAutomaticDeletes = True |
Me.AllowAutomaticInserts = True |
Me.AllowAutomaticUpdates = True |
Me.AllowSorting = True |
Me.EnableEmbeddedSkins = False |
Me.PageSize = 6 |
Me.Width = Unit.Percentage(100) |
Me.Height = Unit.Percentage(100) |
'pager |
Me.PagerStyle.Mode = GridPagerMode.Slider |
'validation |
Me.ValidationSettings.EnableValidation = True |
'client-side settings |
Me.ClientSettings.ReorderColumnsOnClient = True |
Me.ClientSettings.EnablePostBackOnRowClick = True |
Me.ClientSettings.Selecting.AllowRowSelect = True |
Me.ClientSettings.ClientEvents.OnRowClick = "RowClick" |
Me.ClientSettings.ClientEvents.OnRowDblClick = "RowDblClick" |
Me.ClientSettings.ClientEvents.OnCommand = "GridCommand" |
Me.ClientSettings.ClientEvents.OnRowSelected = "rowSelected" |
Me.ClientSettings.ClientEvents.OnRowDeselected = "rowDeselected" |
End Sub |
Public Overloads Overrides Function CreateTableView() As GridTableView |
Return New GridTableViewM(Me) |
End Function |
End Class |
Public Class GridTableViewM |
Inherits GridTableView |
Public Sub New() |
Me.AutoGenerateColumns() = False |
Me.CommandItemDisplay() = GridCommandItemDisplay.Top |
Me.EditMode() = GridEditMode.InPlace |
Me.AllowFilteringByColumn() = True |
Me.CommandItemTemplate = New CommandItemTemplateM() |
End Sub |
Public Sub New(ByVal owner As RadGrid) |
MyBase.New(owner) |
Me.AutoGenerateColumns() = True |
Me.CommandItemDisplay() = GridCommandItemDisplay.Top |
Me.EditMode() = GridEditMode.InPlace |
Me.AllowFilteringByColumn() = True |
Me.CommandItemTemplate = New CommandItemTemplateM() |
End Sub |
End Class |
Public Class CommandItemTemplateM |
Implements ITemplate |
Protected insertButton As LinkButton |
Protected editButton As LinkButton |
Protected copyButton As LinkButton |
Protected deleteButton As LinkButton |
Protected filterViewButton As LinkButton |
Protected modeButton As LinkButton |
Public Sub New() |
MyBase.New() |
End Sub |
Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) Implements System.Web.UI.ITemplate.InstantiateIn |
Dim menuDiv As New System.Web.UI.HtmlControls.HtmlGenericControl("DIV") |
Dim leftMenuDiv As New System.Web.UI.HtmlControls.HtmlGenericControl("DIV") |
leftMenuDiv.Style.Add("float", "left") |
Dim rightMenuDiv As New System.Web.UI.HtmlControls.HtmlGenericControl("DIV") |
rightMenuDiv.Style.Add("float", "right") |
container.Controls.Add(menuDiv) |
menuDiv.Controls.Add(leftMenuDiv) |
menuDiv.Controls.Add(rightMenuDiv) |
'comando NUOVO RECORD |
insertButton = New LinkButton |
insertButton.ID = "insertButton" |
insertButton.Text = "Nuovo" insertButton.CommandName = "InitInsert" |
'comando MODIFICA RECORD SELEZIONATO |
editButton = New LinkButton |
editButton.ID = "editButton" |
editButton.Text = "Modifica" editButton.CommandName = "EditSelected" |
'comando DUPLICA RECORD SELEZIONATO |
copyButton = New LinkButton |
copyButton.ID = "copyButton" |
copyButton.Text = "Duplica" copyButton.CommandName = "" |
'comando ELIMINA RECORD SELEZIONATO |
deleteButton = New LinkButton |
deleteButton.ID = "deleteButton" |
deleteButton.Text = "Elimina" deleteButton.CommandName = "DeleteSelected" |
'comando VISUALIZZA/NASCONDI FILTRI |
filterViewButton = New LinkButton |
filterViewButton.ID = "filterViewButton" |
filterViewButton.Text = "" filterViewButton.CommandName = "EnableDisableFilter" |
'comando CAMBIA MODALITA' RAD GRID |
modeButton = New LinkButton |
modeButton.ID = "modeButton" |
modeButton.Text = "" modeButton.CommandName = "ChangeMode" |
'creazione MENU' DI SX |
leftMenuDiv.Controls.Add(insertButton) |
'leftMenuDiv.Controls.Add(New LiteralControl(" ")) |
leftMenuDiv.Controls.Add(editButton) |
'leftMenuDiv.Controls.Add(New LiteralControl(" ")) |
leftMenuDiv.Controls.Add(copyButton) |
'leftMenuDiv.Controls.Add(New LiteralControl(" ")) |
leftMenuDiv.Controls.Add(deleteButton) |
'leftMenuDiv.Controls.Add(New LiteralControl(" ")) |
leftMenuDiv.Controls.Add(filterViewButton) |
'creazione MENU' DI DX |
rightMenuDiv.Controls.Add(modeButton) |
'rightMenuDiv.Controls.Add(New LiteralControl(" ")) |
End Sub |
End Class |
<RadGM:RadGridM ID="GAllarm" runat="server" DataSourceID="DS_Linq_Allarm_Culture"> |
<MasterTableView> |
<DetailTables> |
<RadGM:GridTableViewM ClientDataKeyNames="IdAllarm,IdCulture" DataKeyNames="IdAllarm,IdCulture" |
DataSourceID="DS_Linq_Allarm_Culture"> |
<Columns> |
<%--Here I defined my columns--%> |
</Columns> |
</RadGM:GridTableViewM> |
</DetailTables> |
</MasterTableView> |
</RadGM:RadGridM> |
but in this way I can't assign my Columns collection to MasterTableView. If I set AutogenerateColumns to true all is correct. How can I let columns definition in aspx page? Can I define some event handler procedure like onItemCreated and onItemCommand in my assembly?
BestRegard
Archimede
I think that the general directions from the 'Telerik RadGrid inheritance' chapter in the online documentation can help you register the columns for your inherited grid. You can refer to this article in particular.
Regards,
Sebastian
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

Best regards,
Archimede
Here is a quote from the same article:
...But the GridTableView, GridBoundColumn etc. classes are defined in the Telerik.Web.UI assembly. That is why the declaration in your grid body should have the following syntax:
ASPX/ASCX | ![]() |
---|---|
<mytelerik: InheritedGrid ... >
<MasterTableView> <Columns> <telerik:GridBoundColumn ...> </telerik: GridBoundColumn> </Columns> <DetailTables> <telerik:GridTableView ...> </telerik:GridTableView> </DetailTables> <MasterTableView> </mytelerik: InheritedGrid> |
Hope this helps.
Regards,
Sebastian
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

I'm in the situation of a "reimplemented" RadGrid and "reimplemented" GridTableView. For this case there isn't any information about Column definition.
BestRegards,
Archimede