Grid Self Referencing Hierarchy Issue

4 posts, 0 answers
  1. Abdurrahman Battal
    Abdurrahman Battal avatar
    20 posts
    Member since:
    Nov 2008

    Posted 05 May 2009 Link to this post

    Hi,

    I am trying to use the grid with self referencing; however I am unable to solve some issues. The first and most important problem is, if I choose "AutoGenerateColumns" as true; it all works fine. However; I need to specify the columns during runtime on serverside; by adding columns to the grid. When "AutoGenerateColumns" is set to false and columns are added on the server side, grid does not display the hierarchy at all; but just lists the items.

    Please let me know what to do to be able to add columns at serverside during page's load or init events; so that the self referencing hierarchy works.

    I am exhausted of trying to solve this issue and tried everything I can; so any help is greatly appreciated.

    Thanks.
  2. Serrin
    Serrin avatar
    286 posts
    Member since:
    Sep 2008

    Posted 05 May 2009 Link to this post

    Hey Abdurrahman,

    I think the problem that you're going to run into with this is that you would need to know the exact setup of the grid beforehand.  In looking into the code from the self-referencing hierarchy demo, there are both GridBoundColumns and GridExpandColumns at work here, so theoretically you would need to have knowledge of how to structure your grid before you could put any data into it to make the hierarchy.

    Out of curiosity, why do you need to create the columns during runtime if the basic self-referencing hierarchy example takes care of creating everything for you?  Knowing this might help some of the Grid-wizards that frequent here to come up some some sort of workaround or trick that could fit your scenario.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Marc Plaxton-Harrison
    Marc Plaxton-Harrison avatar
    38 posts
    Member since:
    Mar 2008

    Posted 07 May 2010 Link to this post

    Hi Serrin,

    I have run into exactly the same problem as Abdurrahman.
    I don't know what his reasoning for it would be, however my purpose is this.

    I have a self-referencing table with fields - ID, Name, Date, ParentID.
    Unfortunately the system i'm developing requires me to only display the Name and Date fields and hide the ID's.
    the only way to accomplish that is to hide the respective columns at run-time in code, which doesn't seem to be working as Abdurrahman stated above.

    I have yet to find resolution to this problem and help would be greatly appreciated.

    Regards
  5. Veli
    Admin
    Veli avatar
    2002 posts

    Posted 12 May 2010 Link to this post

    Hi guys,

    @Mark
    You can still have auto-generated columns in RadGrid. Of all you need is to hide one of them, you can use the ColumnCreated event of the grid. ColumnCreated is fired for auto-generated columns only, so you can check the column name and hide the ID column:

    public void RadGrid1_ColumnCreated(object sender, Telerik.Web.UI.GridColumnCreatedEventArgs e)
    {
        if (e.Column.UniqueName == "ID")
        {
            e.Column.Visible = false;
        }
    }


    @Abdurrahman
    If your columns do not change on postback, i.e. you always create the same set of columns, then the standard rules for programmatic grid creation apply for your case. If your columns may change on postback, then you need to create RadGrid entirely in the code-behind (in Page_Init) and add it to a container on the page (refer to section "Creating the grid entirely in the code-behind" in the linked article).

    Kind regards,
    Veli
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top