This is a migrated thread and some comments may be shown as answers.

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

3 Answers 256 Views
Grid
This is a migrated thread and some comments may be shown as answers.
NLV
Top achievements
Rank 1
NLV asked on 05 Mar 2010, 05:34 AM
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

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 05 Mar 2010, 08:27 AM
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.
0
NLV
Top achievements
Rank 1
answered on 05 Mar 2010, 07:58 PM
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
0
Accepted
Yavor
Telerik team
answered on 10 Mar 2010, 12:33 PM
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.
Tags
Grid
Asked by
NLV
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
NLV
Top achievements
Rank 1
Yavor
Telerik team
Share this question
or