SFDataGrid sort by hidden column

Hi All,

Is it possible or do you have an example or sorting a binded SFDataGrid column using a hidden column or from the binded data. the column would need to be tri state sorting.
Thanks in advance

Regards
Nic

3 Replies 1 reply marked as answer

KK Karthikraja Kalaimani Syncfusion Team June 16, 2021 01:46 PM UTC

Hi Nic,

We prepared sample for your requirement. We applied sort column descriptions for the hidden columns on button click. 

Sample link : https://www.syncfusion.com/downloads/support/directtrac/general/ze/DataGridDemo322698290.zip

Regards,
Karthik Raja

Marked as answer

NI Nic June 16, 2021 09:05 PM UTC

Hi Karthik 

thank you for the sample, if possible i would like to sort by clicking on the column header of the grid, can this be done in SfDatagrid?
I have 6 columns in my grid with one hidden, i would like to click the header of column 5 but the sorting be done on the hidden column 6.

thanks for your time.

Kind Regards
Nic


KK Karthikraja Kalaimani Syncfusion Team June 17, 2021 03:03 PM UTC

Hi Nic, 

Your requirement can be achieved by adding sorting column description if the column index value is 4 on GridTapped event. For more details please, refer to the code snippets below. 

Code snippet : 
  this.dataGrid.GridTapped += DataGrid_GridTapped;
...
 private void DataGrid_GridTapped(object sender, GridTappedEventArgs e)
        {
            if (e.RowColumnIndex.ColumnIndex == 4 && dataGrid.SortColumnDescriptions.Count ==0)
            {
                dataGrid.SortColumnDescriptions.Add(new SortColumnDescription() { ColumnName = "No_2", SortDirection = Syncfusion.Data.ListSortDirection.Descending });
            }
        }
 
Regards,
Karthik Raja

Loader.
Up arrow icon