We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Change the Col position

HI I am using the Grid control. The requriment is the user can change the position of col during runtime. How do I change the position during runtime? Can we have any property to set so that the col will be displayed in that position. Want to move the col right or left..user can palyaround in positioning the column. Pls let me knw ASAP... Cheers Ravi

12 Replies

AD Administrator Syncfusion Team May 25, 2006 11:24 AM UTC

Hi Ravi, To rearrange the columns of the grid, you need to use the Binder.LayoutColumns(). The LayoutColumns() rearranges how the columns should be displayed in the grid and allows you to specify covered cells and / or break records into several rows displayed in the grid. Here is some code snippet this.gridDataBoundGrid1.Binder.LayoutColumns( "Id","Points","Name"); Here is a sample. http://www.syncfusion.com/Support/user/uploads/contextMenu_fb5f7280.zip Please let me know if this helps. Best Regards, Haneef Please note : "-" indicates a covered cell, "." indicates a new row, "" specifies an empty "whitespace" column.


AD Administrator Syncfusion Team May 25, 2006 11:29 AM UTC

Hi Ravi, Set the gridControl1.ControllerOptions |= GridControllerOptions.DragColumnHeader; or the gridControl1.AllowDragSelectedCols = true; to enable moving columns by click and drag at run time. Regards, Calvin.


AD Administrator Syncfusion Team May 25, 2006 11:39 AM UTC

Hi Ravi, To move the cols through code the Model.Cols.MoveRange method can be used. grid.Model.Cols.MoveRange(from,count,target); //to move more than one col grid.Model.Cols.MoveRange(from,target); Regards, Calvin.


RA Ravichandran May 25, 2006 11:45 AM UTC

Hi First thing,I am not using bound grid control I am using GridControl only. Secondaly, I dont want to use mouse options or drag and drop columns. Idea is,we are going to provide an user interface (GUI) to list all the cols user can change the position and also remove (hide) the cols they dont want to see..etc. So once they click ok...the corresponding grid has to be refreshed with these changes ( hide or moving the position etc)... So once clikc OK i have to change the cols collection position. Let me kwno Cheers Ravi >Hi Ravi, > >Set the gridControl1.ControllerOptions |= GridControllerOptions.DragColumnHeader; or the gridControl1.AllowDragSelectedCols = true; to enable moving columns by click and drag at run time. > >Regards, >Calvin.


AD Administrator Syncfusion Team May 25, 2006 01:50 PM UTC

Hi Ravi, The Cols.RemoveRange method can be used to remove the cols and the Cols.Hidden[colIndex] can be set to true to hide the column. Attached is a sample that demonstrates customizing the gridControl’s columns at runtime through a GUI. Regards, Calvin.

CustomizeCols.zip


RA Ravichandran May 25, 2006 02:53 PM UTC

Hi Calvin Thanks. This is what I exactly want. I am going to use implement the same with my application and let you know if I need any help. Cheers Ravi >Hi Ravi, > >The Cols.RemoveRange method can be used to remove the cols and the Cols.Hidden[colIndex] can be set to true to hide the column. Attached is a sample that demonstrates customizing the gridControl’s columns at runtime through a GUI. > >Regards, >Calvin.

CustomizeCols.zip


RA Ravichandran May 25, 2006 02:54 PM UTC

Before that... If I move the cols do we need to bind the datasource again? Ravi >Hi Calvin > >Thanks. This is what I exactly want. I am going to use implement the same with my application and let you know if I need any help. > >Cheers >Ravi > >>Hi Ravi, >> >>The Cols.RemoveRange method can be used to remove the cols and the Cols.Hidden[colIndex] can be set to true to hide the column. Attached is a sample that demonstrates customizing the gridControl’s columns at runtime through a GUI. >> >>Regards, >>Calvin.

CustomizeCols.zip


RA Ravichandran May 25, 2006 04:01 PM UTC

Hi I have tried your code solution in my application. But the column header is moving but no the data. Ravi >Before that... >If I move the cols do we need to bind the datasource again? > >Ravi > >>Hi Calvin >> >>Thanks. This is what I exactly want. I am going to use implement the same with my application and let you know if I need any help. >> >>Cheers >>Ravi >> >>>Hi Ravi, >>> >>>The Cols.RemoveRange method can be used to remove the cols and the Cols.Hidden[colIndex] can be set to true to hide the column. Attached is a sample that demonstrates customizing the gridControl’s columns at runtime through a GUI. >>> >>>Regards, >>>Calvin.

CustomizeCols.zip


AD Administrator Syncfusion Team May 26, 2006 04:29 AM UTC

Hi Ravi, If you are populating the grid through virtual mode then please refer to the below forum thread to know about re-order the columns with a help of a column indexer array. http://www.syncfusion.com/Support/forums/message.aspx?MessageID=43184 And if you are using the PopulateValues method then first populate the grid by calling the PopulateValues method and then customize the columns. Regards, Calvin.


RA Ravichandran May 26, 2006 09:11 AM UTC

Hi But I dont want to drag and drop method. As I said earlier its based on user preference only. I am using Virtual grid only... Cheers Ravi >Hi Ravi, > >If you are populating the grid through virtual mode then please refer to the below forum thread to know about re-order the columns with a help of a column indexer array. > >http://www.syncfusion.com/Support/forums/message.aspx?MessageID=43184 > >And if you are using the PopulateValues method then first populate the grid by calling the PopulateValues method and then customize the columns. > >Regards, >Calvin.


AD Administrator Syncfusion Team May 29, 2006 04:05 AM UTC

Hi Ravi, Attached is the extended sample that demonstrates how to re-order the columns of a virtual grid with a help of a column indexer array. Here is a sample. http://www.syncfusion.com/Support/user/uploads/CustomizeCols_32ea3d59.zip Regards, Calvin.


RA Ravichandran May 30, 2006 10:04 AM UTC

Hi Thanks. Let you know if i need any help. Cheers Ravi >Hi Ravi, > >Attached is the extended sample that demonstrates how to re-order the columns of a virtual grid with a help of a column indexer array. > >Here is a sample. >http://www.syncfusion.com/Support/user/uploads/CustomizeCols_32ea3d59.zip > >Regards, >Calvin. >

Loader.
Live Chat Icon For mobile
Up arrow icon