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

Foreing key

Hi we have a grouping grid like this



The main data source of the grid is a datatable and we have the columns Taxonomy Main and taxonomy Sub setup in this manner:


        GridAlarm.TableDescriptor.Columns("Taxonomy main").ReadOnly = False
        GridAlarm.TableDescriptor.Columns("Taxonomy main").Appearance.AnyCell.HorizontalAlignment = GridHorizontalAlignment.Left
        GridAlarm.TableDescriptor.Columns("Taxonomy main").Appearance.AnyRecordFieldCell.CellType = GridCellTypeName.ComboBox
        GridAlarm.TableDescriptor.Columns("Taxonomy main").Appearance.AnyRecordFieldCell.DataSource = alarmLibrary.getTaxonomy_Main(m_cnnstring)
        GridAlarm.TableDescriptor.Columns("Taxonomy main").Appearance.AnyRecordFieldCell.ValueMember = "sk_Taxonomy_Main"
        GridAlarm.TableDescriptor.Columns("Taxonomy main").Appearance.AnyRecordFieldCell.DisplayMember = "description"
        GridAlarm.TableDescriptor.Columns("Taxonomy main").Appearance.AnyRecordFieldCell.AutoFit = AutoFitOptions.Alphabet
        GridAlarm.TableDescriptor.Columns("Taxonomy main").Appearance.AnyRecordFieldCell.DropDownStyle = GridDropDownStyle.AutoComplete
        GridAlarm.TableDescriptor.Columns("Taxonomy main").Appearance.AnyCell.WrapText = False
        GridAlarm.TableDescriptor.Columns("Taxonomy main").Appearance.AnyCell.AutoSize = True

        GridAlarm.TableDescriptor.Columns("Taxonomy sub").ReadOnly = False
        GridAlarm.TableDescriptor.Columns("Taxonomy sub").Appearance.AnyCell.HorizontalAlignment = GridHorizontalAlignment.Left
        GridAlarm.TableDescriptor.Columns("Taxonomy sub").Appearance.AnyRecordFieldCell.CellType = GridCellTypeName.ComboBox
        GridAlarm.TableDescriptor.Columns("Taxonomy sub").Appearance.AnyRecordFieldCell.DataSource = alarmLibrary.getTaxonomy_Sub(-1, m_cnnstring) 
        GridAlarm.TableDescriptor.Columns("Taxonomy sub").Appearance.AnyRecordFieldCell.ValueMember = "key_value"
        GridAlarm.TableDescriptor.Columns("Taxonomy sub").Appearance.AnyRecordFieldCell.DisplayMember = "description"
        GridAlarm.TableDescriptor.Columns("Taxonomy sub").Appearance.AnyRecordFieldCell.AutoFit = AutoFitOptions.Alphabet
        GridAlarm.TableDescriptor.Columns("Taxonomy sub").Appearance.AnyRecordFieldCell.DropDownStyle = GridDropDownStyle.AutoComplete
        GridAlarm.TableDescriptor.Columns("Taxonomy sub").Appearance.AnyCell.WrapText = False
        GridAlarm.TableDescriptor.Columns("Taxonomy sub").Appearance.AnyCell.AutoSize = True

the data source of this 2 combo is a data table

we need to filter the combo in taxonomy sub with the value member of the taxonomy main beacuse for each taxonomy main we have a small set of Taxonomy sub
How is possible to achieve this ? can you help us ?

Than you for your support

Franco




9 Replies

AR Arulpriya Ramalingam Syncfusion Team August 14, 2017 05:25 PM UTC

Hi Franco, 
 
Thanks for using Syncfusion products. 
 
By default, the records will be filtered based on the ValueMember for the ComboBox column. In order to Filter a ComboBox column based on another ComboBox value member, programmatic filter can be added to the GridGroupingControl by using RecordFilterDescriptor and the condition for the filter descriptor can be added by using the FilterCondition. We have modified the sample as per your requirement. Please make use of below code and sample, 
 
Code snippet 
 
 
//To add the FilterCondition 
FilterCondition condition = new FilterCondition((FilterCompareOperator.Like), "3"); 
RecordFilterDescriptor recordFilter = new RecordFilterDescriptor("CategoryID", condition); 
 
// Add the RecordFilterDescriptor to the RecordFilters. 
this.gridGroupingControl1.TableDescriptor.RecordFilters.Add(recordFilter); 
 
 
Sample link: ComboBox_Filtering  
 
Arulpriya 



GM Gangabharathy Murugasen Syncfusion Team August 16, 2017 04:27 AM UTC

Thank you Arulpriya for our support 
but in thi case all grid is filtererd, I need to filter only the value in the second combo box , it's a cascading filter 
Regards 
Franco 



FP franco perduca August 16, 2017 07:11 PM UTC

Thank you Arulpriya for our support 
but in thi case all grid is filtererd, I need to filter only the value in the second combo box , it's a cascading filter 
Regards 
Franco


MG Mohanraj Gunasekaran Syncfusion Team August 17, 2017 07:27 AM UTC

Hi Franco,  
  
Sorry for the inconvenience caused.  
  
By default, GridGroupingControl, does not have the direct support to filter the combobox source based on another combobox value. But, this scenario can be achieved by using QueryCellStyleInfo event. Please refer to the below code example,  
  
Code example  
this.gridGroupingControl1.QueryCellStyleInfo += gridGroupingControl1_QueryCellStyleInfo;  
  
void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)  
{  
    if (e.TableCellIdentity == null || e.TableCellIdentity.Column == null)  
        return;  
    if (e.TableCellIdentity.Column.Name == "SampleData")  
    {  
        Element el = e.TableCellIdentity.DisplayElement;  
        if (el != null && el.Kind == DisplayElementKind.Record)  
        {  
            Record record = el.GetRecord();  
            //Get the first column cell value  
            String value = record.GetValue("CategoryID").ToString();  
            //Get the collection based on the first column value  
            List<CasCading> source = comboSource[value];  
            //Assign the collection for second column.  
            e.Style.DataSource = source;  
            e.Style.DisplayMember = "SData";  
        }  
    }  
}  
 
  
Sample link: GridGroupingControl  
 
Please let us know if we misunderstood your scenario. 
 
Regards,  
Mohanraj G  
 



FP franco perduca August 17, 2017 01:55 PM UTC

Thank you Mohanraj

but your sample does not work , no change appear in the grid....

regards franco



FP franco perduca August 18, 2017 04:04 PM UTC

Thank you Mohanraj

But this event is raised at infinity.... and is very slow is not Is not applicable

ther is some workaround ?

regards franco



AR Arulpriya Ramalingam Syncfusion Team August 20, 2017 04:57 AM UTC

Hi Franco, 
 
Thanks for your update. 
 
In the provided sample of last update, we have set the data source for a ComboBox column based on the ValueMember of another ComboBox column. So, the records will not be filtered and changes will not be reflect in the grid. We are little bit unclear about your scenario. Can you please elaborate the scenario or provide any screenshot/video of your exact requirement so that we could provide you a better solution at the earliest? 
 
Regards, 
Arulpriya 



FP franco perduca replied to Arulpriya Ramalingam August 20, 2017 07:08 PM UTC

Hi Franco, 
 
Thanks for your update. 
 
In the provided sample of last update, we have set the data source for a ComboBox column based on the ValueMember of another ComboBox column. So, the records will not be filtered and changes will not be reflect in the grid. We are little bit unclear about your scenario. Can you please elaborate the scenario or provide any screenshot/video of your exact requirement so that we could provide you a better solution at the earliest? 
 
Regards, 
Arulpriya 


Hi Arulpriya 

Thank you for your support

We have 2 combo in gridgoruping control (refer to screenshoot in the first my post)

tthe first contain a Taxonomoy Main when this change during the edit the Taxonomy Sub (the second combo ) need to be filtered by the valuemember in the taxonomy main;

it's a cascading lookup like a product category (Taxonomoy Main) filter the product (Taxonomy sub)

Let me know if this sample is clear

Thank you again

Franco

Regards




AR Arulpriya Ramalingam Syncfusion Team August 21, 2017 12:56 PM UTC

Hi Franco, 
 
We have created a new incident for better follow-up under your account. Please follow-up with that incident. 
 
 
Regards, 
Arulpriya 


Loader.
Live Chat Icon For mobile
Up arrow icon