1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / How do I customize RadGrid?

How do I customize RadGrid?

8 posts, 0 answered
  1. chris_cf
    chris_cf avatar
    32 posts
    Registered:
    04 Jul 2007
    04 Nov 2008
    Link to this post
    I have added RadGrid to the control list in SF. I can click and drag it onto the page fine and edit its properties. How do I customize things like MasterTableView, NestedViewTemplate, etc.

    Do I have to create a custom control and then upload it to the list of controls? If so, is it that having RadGrid in the controls list is just for generic use of RadGrid?
  2. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    04 Nov 2008
    Link to this post
    Hello Chris,

    We would recommend you wrap RadGrid control in a user control and implement the required functionality in it. Then you should register the newly created control in the <toolboxControls> section of the project web.config file like this:

    <toolboxControls> 
    ... 
    <add name="My User Control" section="Custom Controls" 
    URL="~/YourUserControl.ascx" description="some descriptive text" 
    overrideToolboxItem="False" /> 
    ... 
    </toolboxControls> 

    For details how to work with the Telerik RadGrid please refer to RadGrid for ASP.NET AJAX online documentation.

    Regards,
    Pepi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. chris_cf
    chris_cf avatar
    32 posts
    Registered:
    04 Jul 2007
    04 Nov 2008
    Link to this post
    Hi Pepi,

    Thanks for your response.

    Can you give me an scenario where one would use the RadGrid control directly vs wrapping it in a user control?
  4. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    05 Nov 2008
    Link to this post
    Hi Chris,

    Here is a simple example:

    .ascx
    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="RadGridWrapper.ascx.cs" Inherits="RadGridWrapper" %> 
     <telerik:RadGrid 
       id="RadGrid1" 
       runat="server" 
       OnNeedDataSource="RadGrid1_NeedDataSource"
     <MasterTableView AutoGenerateColumns="True" /> 
    </telerik:RadGrid>  

    .ascx.cs
    using System; 
    using System.Collections; 
    using System.Configuration; 
    using System.Data; 
    using System.Web; 
    using System.Web.Security; 
    using System.Web.UI; 
    using System.Web.UI.HtmlControls; 
    using System.Web.UI.WebControls; 
    using System.Web.UI.WebControls.WebParts; 
    using Telerik.Web.UI; 
     
    public partial class RadGridWrapper : System.Web.UI.UserControl 
        protected void Page_Load(object sender, EventArgs e) 
        { 
     
        } 
     
        protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e) 
        { 
            ArrayList list = new ArrayList(); 
            list.Add("string1"); 
            list.Add("string2"); 
            list.Add("string3"); 
     
            RadGrid1.DataSource = list; 
        }  
     

    For your convenience I have attached the full example. To test it you need just to upload the control through Sitefinity interface.

    Regards,
    Pepi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  5. chris_cf
    chris_cf avatar
    32 posts
    Registered:
    04 Jul 2007
    05 Nov 2008
    Link to this post
    Thanks Pepi.

    However, I was asking for more of an explanation as to why one would use the RadGrid WITHOUT wrapping it in a user control.
  6. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    06 Nov 2008
    Link to this post
    Hi Chris,

    The user could use the RadGrid directly on the page if he just wants to display the data and does not need any complex functionality. But we would strongly recommend wrap RadControl in a user control and then customize it according to your requirements. User controls are easy to add to any web page once you created them. So there is no need to code again the same functionality if it is used in another page of the web application.

    Best wishes,
    Pepi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  7. chris_cf
    chris_cf avatar
    32 posts
    Registered:
    04 Jul 2007
    06 Nov 2008
    Link to this post
    Thanks, Pepi.

    As I'm new to Sitefinity, I'm just trying to wrap my head around the best practices and the DOs and DON'Ts.
  8. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    06 Nov 2008
    Link to this post
    Hello chris_cf,

    Perhaps you may find this video helpful: Customizing existing Sitefinity public controls.

    Don't hesitate to contact us if you have other questions.

    Greetings,
    Georgi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Register for webinar
8 posts, 0 answered