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

GGC Excel-Filter sorting by Displaymember

Hello,

is it possible to sort in a GGC Excel-Filter (see attachment) the entries by DisplayMember?

I tried:
            foreach (var column in gridGroupingControlVehicle.TableDescriptor.Columns)
            {
                column.SortByDisplayMember = true;
                column.AllowFilter = true;
            }

Thanks for your support
BR Thomas

Attachment: GGC_Filter_Sorting_By_DisplayMember_18d3507c.zip

5 Replies

AA Arulraj A Syncfusion Team January 17, 2019 06:11 AM UTC

Hi Thomas, 

Thanks for using Syncfusion product. 

To sort the values in GridExcelFilter listview based on the DisplayMember, you could use the FilterRowOptions.FilterMode property. Please refer the following code example. 

C# 
//ComboBox column 
this.gridGroupingControl1.TableDescriptor.Columns["Country"].FilterRowOptions.FilterMode = FilterMode.DisplayText; 
//Or 
  foreach (var column in gridGroupingControlVehicle.TableDescriptor.Columns) 
{ 
    column.FilterRowOptions.FilterMode = FilterMode.DisplayText; 
        column.AllowFilter = true; 
} 
 

Regards,  
Arulraj A 



TH Thomas January 27, 2019 08:10 AM UTC

Hello,

thanks for your replay.
I tried your solution in my code, but it did not work. Then I tried your solution in the attachment and it did not work either (see the screenshot in the attachment).

BR Thomas

Attachment: 20190127_09_02_57GridGroupingControl_7a03b71b.zip


AA Arulraj A Syncfusion Team January 28, 2019 12:25 PM UTC

Hi Thomas, 

Thanks for your update. 

By default, ComboBox column loads the items based on the binding collection so, GridGroupingControl does not have the direct support to sort the dropdown items. But, you could achieve your requirement by using CurrentCellShowingDropDown event. Please refer the following code example. 

C# 
this.gridGroupingControl1.TableControl.CurrentCellShowingDropDown += TableControl_CurrentCellShowingDropDown; 
private void TableControl_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs e) 
{ 
    GridCurrentCell currentCell = this.gridGroupingControl1.TableControl.CurrentCell; 
    GridTableCellStyleInfo style = this.gridGroupingControl1.TableControl.GetTableViewStyleInfo(currentCell.RowIndex, currentCell.ColIndex); 
    GridComboBoxCellRenderer renderer = this.gridGroupingControl1.TableControl.CurrentCell.Renderer as GridComboBoxCellRenderer; 
    if (renderer != null) 
    { 
        var list = renderer.ListBoxPart.Items.Cast<DataRowView>().OrderBy(x => x.Row[1]).ToList(); 
        renderer.ListBoxPart.DataSource = null; 
        if (style.HasDisplayMember) 
        { 
            renderer.ListBoxPart.DisplayMember = style.DisplayMember; 
            renderer.ListBoxPart.ValueMember = style.ValueMember; 
        } 
        renderer.ListBoxPart.DataSource = list; 
    } 
} 
 

Arulraj A 



TH Thomas September 5, 2019 12:46 PM UTC

Hello,

thanks for your solution, but when I try, the sort does not work (see the attachment).

I need: China, England, India, Pune, UK and USA.

Thanks for your support
Thomas 

Attachment: 20190905_14_40_49GridGroupingControl_696f4a15.zip


AR Arulpriya Ramalingam Syncfusion Team September 6, 2019 07:04 AM UTC

Hi Thomas,   
   
Thanks for the update.   
   
The GridExcelFilter for the GridGroupingCotnrol does not have the default or customization support for the FilterPopUp. Moreover, the CheckedBoxList items will be added by retrieving each record value for the column and add the unique value to the list and the Checked box items could not be retrieved at sample level to sort it manually. Also, the Sort A to Z or Sort Z to A will sort the grid records but not the filter popup items. So, we regret to let you know that the GridExcelFilter for the GridGroupingControl does not have any built-in or extensible support to customize the filter drop down of ExcelFilter.   
   
Please revert to us, if you have any other queries.   
   
Regards,   
Arulpriya   


Loader.
Live Chat Icon For mobile
Up arrow icon