Creating a column in runtime and inserting it in a specific position (column order)

4 posts, 1 answers
  1. NLV
    NLV avatar
    87 posts
    Member since:
    Aug 2009

    Posted 04 Mar 2010 Link to this post

    Hello

    I've a radgrid in my application. I've specified the bound columns for the rad grid in the aspx page.

    Now at the run time i want to add another column and insert it in a specific position in the radgrid. I want to persist it across the postbacks invoked by sorting, filtering etc.

    Any insights on this?

    Thank you
    NLV
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 05 Mar 2010 Link to this post

    Hello,

    You can set the OrderIndex property of columns as required, without conflicting/missing the order. The OrderIndex property lets you change the position of columns to move them to a specific location.

    Go through the following documentation which might helpful in this.

    -Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. NLV
    NLV avatar
    87 posts
    Member since:
    Aug 2009

    Posted 05 Mar 2010 Link to this post

    Thanks for your reply.
    But i've written an ugly code to get it work. The column order is getting set properly if i only follow the steps below

    • Create a new column
    • Add it to the grid
    • Set the properties of the new column
    • Databind
    • Get the newly added column (FindByDataField)
    • Set the Column order index
    • Databind

    Any other solution?

    Thank you

    Regards
    NLV
  5. Answer
    Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 10 Mar 2010 Link to this post

    Hello NLV,

    Basically, in order to make sure that the control's structure is properly persisted, you need to create it accordingly. The following topic:

    http://www.telerik.com/help/aspnet-ajax/grdchanginggridstructuredynamically.html

    contains more information on one possible way to alter the columns of the control. I hope it gets you started properly.

    Best wishes,
    Yavor
    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