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

Grouping with GridMultiColumnDropDownList

Hi,

I have a SfDataGrid that have a column of type GridMultiColumnDropDownList.

I have these bindings:

ItemsSource="{Binding AuxiliaryCodes.AuxiliaryListValues}"
MappingName="AuxiliaryListValue_ID"
ValueMember="ID"

and these columns:

                        <Syncfusion:GridMultiColumnDropDownList.Columns>
                            <Syncfusion:Columns>
                                <Syncfusion:GridTextColumn MappingName="Code" HeaderText="Code}"  />
                                <Syncfusion:GridTextColumn MappingName="Description" HeaderText="Description"  />
                            </Syncfusion:Columns>
                        </Syncfusion:GridMultiColumnDropDownList.Columns>

The column is binded to an object with a column named "AuxiliaryList_ID" of type int?.
The combo-box is binded to a list of objects that have 2 properties named Code and Description and a ID (used to bind the value).
I use the GridMultiColumnDropDownList to display in the popup grid both the string columns when the user selects an object.
Everything work very good but I have a little problem with grouping.
In fact when I group using this column, I obtain as keys the ID numbers and not the Code value of the selected records that i see in the cells.

I've found this link that explains how to probably solve the problem if I used a GridComboBoxColumn.

https://www.syncfusion.com/kb/3446/how-to-change-the-groupcaptiontext-based-on-display-member-of-the-gridcomboboxcolumn

But I'm not able to figure out how to implement a similar way for the GridMultiColumnDropDownList column.

Can you help me?

Regards,

Silvio

5 Replies

FP Farjana Parveen Ayubb Syncfusion Team January 15, 2016 11:34 AM UTC

Hi  Silvio,

Thank you for contacting Syncfusion support.

We have analyzed your query. You can achieve your requirement “Group Key based on DisplayMemberPath” by setting GroupColumnDescription.Converter property in GroupColumDescrptionCollectionChanged event in SfDataGrid.

Please refer the below code example and sample in the following location:

Code Example(C# - Converter):
   public class GroupcaptionConverterMultiColumnDropDownList : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (!(parameter is GridMultiColumnDropDownList))
                return value;
            var column = parameter as GridMultiColumnDropDownList;
            var record = value as EmployeeInfo;
            var itemsSource = column.ItemsSource as ObservableCollection<CompanyItem>;
            foreach (var item in itemsSource)
            {
                if (record.CountryCode == (item as CompanyItem).CountryCode)
                    return (item as CompanyItem).CountryName;
            }
            return null;
        }
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

Code Example(C# - GroupColumnDescriptionsCollectionChanged):
   void GroupColumnDescriptions_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                var group = e.NewItems[0] as GroupColumnDescription;
                if (group.ColumnName == "CountryCode")
                    group.Converter = new GroupcaptionConverterMultiColumnDropDownList();
            }
        }

Sample Location: MultiColumnDropDownList_Demo


Please let us know if you required any further assistance.

Regards,
Farjana Parveen A



SI Silvio January 15, 2016 03:07 PM UTC

Thank you very much. It's very clear. I was able to fix my problem very quickly !


JG Jai Ganesh S Syncfusion Team January 18, 2016 05:39 AM UTC

Hi Silvio,

Thank you for the update.

Please let us know if you need further assistance on this.

Regards,
Jai Ganesh S


SI Silvio May 25, 2016 02:50 PM UTC

Hi, 

I have now a problem with this SfDatagrid with combo-box grouping, trying to print it with the "ShowPrintPreview" method.

When I have a grouping on one of these combo-boxes in the grid, and I try to print the grid,
NO converter is called when rendering the grid for the printing.
So I don't obtain what I'd like in the report, that's not the same as I have in the GUI.

Can you help me ?


SV Srinivasan Vasu Syncfusion Team May 27, 2016 02:11 AM UTC

Hi Silvio, 
 
We have analyzed your query and the converter will not be fired while printing SfDataGrid with grouping. But the caption summary row will be printed as like in SfDataGrid without using any converter and for your reference we have attached the PrintPreview image and tested sample. Could you please share more details about the issue? Otherwise modify the attached sample as per your application which will be helpful for us to provide appropriate solution. 
 
Sample and Image Location: Image 
 
Regards,
Srinivasan 
 



Loader.
Live Chat Icon For mobile
Up arrow icon