Exposgin Column Collection in a User Control for RadGrid

2 posts, 0 answers
  1. Jolly
    Jolly avatar
    3 posts
    Member since:
    Dec 2012

    Posted 25 Dec 2018 Link to this post

    I was trying to create a User Control for standardizing the Grid Control across all the forms. Surely all the forms will have different columns but the layout is the same across except for few properties here and there. How do I expose the Column Collection?

    My Code would be:

    <telerik:RadGrid ID="grid" runat="server" AllowCustomPaging="false" AllowPaging="False" AllowSorting="False" AutoGenerateColumns="False" CellPadding="0" CellSpacing="0" CssClass="gridCandidate" Height="100%" Width="100%">
            <ClientSettings EnableAlternatingItems="false" EnableRowHoverStyle="true">
                <Scrolling AllowScroll="true" UseStaticHeaders="true" />
                <Selecting AllowRowSelect="True" />
                <ClientEvents OnRowDataBound="function() {}" OnCommand="function(){}" />
            <MasterTableView AllowFilteringByColumn="False" AllowNaturalSort="false" ClientDataKeyNames="ID" DataKeyNames="ID" EnableColumnsViewState="False" EnableViewState="False" HierarchyLoadMode="Client"
                NoMasterRecordsText="<div class='noRec'>No records to display.</div>" TableLayout="Auto">
    <HeaderStyle Height="0px" />
                <PagerStyle Visible="False" />



    [MergableProperty(false), DefaultValue((string)null),
    public GridColumnCollection Columns
            return grid.Columns;
            foreach (GridColumn column in value)


    Any idea how to expose the Columns property?

  2. Marin Bratanov
    Marin Bratanov avatar
    5707 posts

    Posted 27 Dec 2018 Link to this post


    Perhaps the following thread can help you get started with this: https://stackoverflow.com/questions/120997/asp-nested-tags-in-a-custom-user-control.

    You may also find it easier to set settings globally if you implement a control adapter, a ASP.NET Theme or to inherit RadGrid to your own class with some defaults. 

    Of course, the choice would be entirely up to the application development team and their preferences, as neither of these features is related to our controls and is an architectural decision that is in the scope of the application logic and developer preferences.

    Marin Bratanov
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top