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

Telerik Radgrid is not showing columns in the correct order when the order is set programatically

1 Answer 216 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Erwin Walter Benjamin
Top achievements
Rank 1
Erwin Walter Benjamin asked on 19 Aug 2011, 03:06 PM
Hi Telerik team, I've been working on a solution requiring that the columns order can be editable, the RadGrid control we are using is on a SharePoint Webpart. We have an editor part where the page manager can edit the order of the columns. When the editing of the webpart is saved & closed the new data is passed to the RadGrid control to update. All the functionality works as expected except the order. This order is set programatically to the columns as it is configured on the editor part, we checked that the column.position is set correctly but the RadGrid is not re-ordering the columns when the Save & Close its done.
We want some support to make this work if possible.

Fun Fact: If any of the filters, grouping, or re order is done on the control (generating a Post-back) all the columns re-order with the specified order in the editor part.

Thanks in advance!!

Here is our code where we set the position of the columns:

Column column = new Column();
                    column.Name = ((Label) repeaterItem.FindControl("lblColumnName")).Text;
                    column.Id = GetColumnId(column.Name);
                    column.Display = ((CheckBox) repeaterItem.FindControl("chkDisplay")).Checked;
                    column.Position = Convert.ToInt32(((DropDownList) repeaterItem.FindControl("ColumnsDropDown")).SelectedItem.Text);
                    colunns.Add(column);

We set these attributes for each columns displayable on the RadGrid control.

Mr. Erwin W. B. Gutbrod
.NET/Sharepoint Developer Jr.

1 Answer, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 24 Aug 2011, 09:03 AM
Hi Erwin,

When columns are created programmatically, they appear in the RadGrid in the same order as they were added to the Columns collection. You can reorder columns dynamically on the server-side using:
SwapColumns(String,String) Method which accepts the UniqueNames for the columns.
More information you could find on the following link:
http://www.telerik.com/help/aspnet/grid/grdreorderingcolumns.html

Please give it try and let me know if the issue still persists.

All the best,
Radoslav
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
Grid
Asked by
Erwin Walter Benjamin
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Share this question
or