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

Conditional Lookups

I have question about GridGroupingControl: How to display lookup data in the combobox depend on condition from other column?

If I will use approach with GridRelationDescriptor then it will not works cause I need filter related data source (add/remove items) depend on value in the column of selected row. In it's turn it will break representation cause number of cells will become blank from absence data in the related datasource.

May be it make sense to display my custom combobox control with filtered values when user edit value. How to do that?


1 Reply

RC Rajadurai C Syncfusion Team November 23, 2009 10:36 AM UTC

Hi Sergey,

Thanks for your interest in Syncfusion Products.

I apologize for the delay caused in responding.

To customize the dropdownlist in a combobox cell based on the other column value of that corresponding record, you can handle the TableControlCurrentCellActivated and TableControlCurrentCellShowingDropDown events with similar kind of code as shown below which is implemented in the attached sample.

GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(e.TableControl.CurrentCell.RowIndex, e.TableControl.CurrentCell.ColIndex);
GridCurrentCell cc = e.TableControl.CurrentCell;
if (style.TableCellIdentity.Column.Name == "Department" && cc.Renderer is GridComboBoxCellRenderer)
{
GridComboBoxCellRenderer rend = cc.Renderer as GridComboBoxCellRenderer;
if (rend != null)
{
if (style.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Record)
{
Record rec = style.TableCellIdentity.DisplayElement.GetRecord();
if (rec.GetValue("Year").ToString() == "I")
{
rend.ListBoxPart.Items.Clear();
rend.ListBoxPart.Items.AddRange(new object[] { "CIVIL", "MECHANICAL", "EEE", "ECE" });
}
else if (rec.GetValue("Year").ToString() == "II")
{
rend.ListBoxPart.Items.Clear();
rend.ListBoxPart.Items.AddRange(new object[] { "CSE", "IT", "BIO-TECH", "AERO" });
}
else if (rec.GetValue("Year").ToString() == "III")
{
rend.ListBoxPart.Items.Clear();
rend.ListBoxPart.Items.AddRange(new object[] { "MARINE", "CSE", "TEXTILE", "ECE" });
}
else if (rec.GetValue("Year").ToString() == "IV")
{
rend.ListBoxPart.Items.Clear();
rend.ListBoxPart.Items.AddRange(new object[] { "EEE", "MECHANICAL", "CSE", "AERO" });
}
}
}
}

Sample:
F91399-1524680981.zip

Regards,
Rajadurai

Loader.
Live Chat Icon For mobile
Up arrow icon