How to unsort a column set to group in a grid

Hi,

I want to know how to unsort a column set to group in a grid.

I know that setting a group on a grid requires sorting by default, but I want to see the data from the grid (which I didn't do anything to after receiving the data) unsorted on the column I set to group.

Please let me know if there's a property I can work around.




3 Replies

DM Dineshnarasimman Muthu Syncfusion Team August 7, 2023 04:34 PM UTC

Hi sohyeonbak,


Greetings from Syncfusion support.


The grid actions like filtering, sorting, and grouping are based on the field values of the column. Grid doesn’t require sorting in order to perform grouping action. We have attached a sample for your reference.


Sample: https://stackblitz.com/edit/react-6zade7?file=index.js


Can you please provide the following information which will be very helpful for us to provide better solution.


  • Can you please explain your query briefly which will be very helpful for us to identify the issue.
  • Can you please ensure whether you need to unsort the grid programmatically.
  • If possible, can you please provide the sample in which you face issue.


Regards,

Dineshnarasimman



SO sohyeonbak August 8, 2023 09:05 AM UTC

thank you for your answer


When you make the grouped columns visible, you will only be able to see them in ascending and descending order.

In the above situation, I want to un-sort the columns.



code




DM Dineshnarasimman Muthu Syncfusion Team August 9, 2023 01:25 PM UTC

Hi Sohyeonbak,


After reviewing your query, we understand that you don’t need the grouped columns to be sorted. We suggest you to use sortComparer property. This property allows you to customize the sorting behavior for a specific column. By implementing a custom sorting function, we can customize the sort action for a specific column. The code snippet and sample have been attached for your reference. We have also attached the documentation of sortComparer for your reference.


const sortComparer = (reference, comparer) => {

return -1;

};

<ColumnDirective

field="CustomerName"

headerText="Customer Name"

width="150"

sortComparer={sortComparer}

validationRules={validationRule}

>ColumnDirective>


Sample: https://stackblitz.com/edit/react-6zade7-pwe6xy?file=index.js


Documentation: https://helpej2.syncfusion.com/react/documentation/grid/sorting#custom-sort-comparer


Please let us know if you need any further assistance.


Regards,

Dineshnarasimman M


Loader.
Up arrow icon