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

How to sort GridGroupingControl from code behind?

Hi,
Please tell me how to sort the grid grouing control from code behind since the grid get populated at runtime hence there is need to sort the control at runtime.

Please guide me. Please tell me fast what have to do?


Warm Regards,
Dhiraj Karmalkar

10 Replies

AD Administrator Syncfusion Team January 16, 2007 04:09 PM UTC

Hi Dhiraj,

Thank you for being patience.

You can sort the GridGroupingControl columns programmatically by using the following code snippet.
>>>>>>>>>>>>>Code Snippet<<<<<<<<<<<
this.gridGroupingControl1.TableDescriptor.SortedColumns.Add("Column2");
>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<

Please refer to our shipped browser samples [ \\windows\Grid.Grouping.Windows\Samples\Sorting ] for more details.

Kindly let us know if you need any further assistance.
Have a nice day.

Best regards,
Madhan


AD Administrator Syncfusion Team January 16, 2007 04:19 PM UTC

Hi Dhiraj,

Please refer to the following sample which demonstrates the sorting of the column, the data’s are being loaded at runtime.

Sample : GGC_SortingColumns.zip

Best regards,
Madhan


AD Administrator Syncfusion Team January 21, 2007 08:30 AM UTC


Hi Madhan,

Thanks for sample code but I am using grid in the asp.net. One more thing is that whenever I assign DataSource from DataTable it take all the columns from the datatable that I don't want so I set them false and again I am setting it's properties so from here I can not able to see the tringle icon for sorting. Is there any way to make it visible?

please guide me.

Thanks and Regards,
Dhiraj Karmalkar



>Hi Dhiraj,

Please refer to the following sample which demonstrates the sorting of the column, the data’s are being loaded at runtime.

Sample : GGC_SortingColumns.zip

Best regards,
Madhan


GB Gokul B Syncfusion Team January 22, 2007 06:33 PM UTC

Hi Dhiraj,

I apologize for the delay in responding.

You can remove a particular column programmatically by using the following code snippet.

this.GridGroupingcontrol1.TableDescriptor.VisibleColumns.Remove("ColumnName");

However,Please have a look at our attached sample which illustrates the Column Removing and sorting of the particular column.

Forum_54712.zip

Please try this and Let us know if you need any other queries.

Regards,
Gokulkumar.B





DH Dhiraj January 23, 2007 07:03 AM UTC

Hi Gokulkumar,

Thanks for code sample. Here I have attached the sample for my application where I am taking values from database and when I assign datatable to grid it takes all the Columns from the datatable that what I don't want. So I removed one column but trouble I am getting is that I don't want header names as that of those are coming from the database I want these to be different one that is I want to set them manually from code behind.

Which is not working! Tell me any method by which this can be achieved?


Thanks and Regards,
Dhiraj K




>Hi Dhiraj,

I apologize for the delay in responding.

You can remove a particular column programmatically by using the following code snippet.

this.GridGroupingcontrol1.TableDescriptor.VisibleColumns.Remove("ColumnName");

However,Please have a look at our attached sample which illustrates the Column Removing and sorting of the particular column.

Forum_54712.zip

Please try this and Let us know if you need any other queries.

Regards,
Gokulkumar.B





GridTest20.zip


GB Gokul B Syncfusion Team January 23, 2007 04:02 PM UTC

Hi Dhiraj,

Please refer to our below code snippet to change the name of the column to be displayed in the column header.

'Gets the ColumnDescriptor for the specified Column
Dim grid1 As GridColumnDescriptor = GridGroupingControl1.TableDescriptor.Columns.GetColumnDescriptor("CustomerName")
'Changes the name of the column to be displayed in the Column header.
grid1.HeaderText = "Name"

Let us know if you need any other help.

Regards,
Gokulkumar.B


DH Dhiraj January 24, 2007 03:44 AM UTC

Hi Gokulkumar,

Thanks for help it's reallly helpfull but one I can not able to get the sort icon after doing this.

But rest of things are working fine. Well thanks for the help. It was really great.

Thanks and Regards,
Dhiraj Karmalkar




>Hi Dhiraj,

Please refer to our below code snippet to change the name of the column to be displayed in the column header.

'Gets the ColumnDescriptor for the specified Column
Dim grid1 As GridColumnDescriptor = GridGroupingControl1.TableDescriptor.Columns.GetColumnDescriptor("CustomerName")
'Changes the name of the column to be displayed in the Column header.
grid1.HeaderText = "Name"

Let us know if you need any other help.

Regards,
Gokulkumar.B


DH Dhiraj January 24, 2007 10:12 AM UTC

Hi Gokulkumar,

I have one more doubt about is that if initially I have nothing to show in the grid then on some server event, I am displaying the grid columns but what happening is that I can not able to see the grid columns and it gives error or it gives same error that earlier I got. So I explicitely added the grid columns but then I can not able to see the grid sort icon.

Please guide me.

Thanks and Regards,
Dhiraj K






>Hi Gokulkumar,

Thanks for help it's reallly helpfull but one I can not able to get the sort icon after doing this.

But rest of things are working fine. Well thanks for the help. It was really great.

Thanks and Regards,
Dhiraj Karmalkar




>Hi Dhiraj,

Please refer to our below code snippet to change the name of the column to be displayed in the column header.

'Gets the ColumnDescriptor for the specified Column
Dim grid1 As GridColumnDescriptor = GridGroupingControl1.TableDescriptor.Columns.GetColumnDescriptor("CustomerName")
'Changes the name of the column to be displayed in the Column header.
grid1.HeaderText = "Name"

Let us know if you need any other help.

Regards,
Gokulkumar.B


AD Administrator Syncfusion Team January 25, 2007 09:07 AM UTC

Hi Dhiraj,

Below specified code helps you to get the 'Sort' icon on the renamed Column Header

grid1.TableDescriptor.SortedColumns.Add("CustomerName",ListSortDirection.Ascending)

Please let us know if you need any further assistance.

Regards,
Valli.


DH Dhiraj February 2, 2007 06:52 AM UTC

hi Valli,

Thanks for the suggestion but that didn't worked for me but I solved it whith different approach.

Thanks

Warm Regards,
Dhiraj Karmalkar

Loader.
Live Chat Icon For mobile
Up arrow icon