Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
115
Filter BindableValueList Dropdown In WinGrid
posted

I'm new using infragistics so this might be a simple question, so here goes:

I have a UltraGridColumn that has style of ColumnStyle.DropDownList. The column ValueList is set to a BindableValueList. All this is wired up in the InitLayout event method.

void ultraGrid_InitializeLayout(object sender, InitializeLayoutEventArgs e)

Once that method completes, I have a dropdown with values as expected.

Now the goal is to remove specific items from the dropdown list when user clicks it. I added this

ugc.Editor.BeforeEnterEditMode += Editor_BeforeEnterEditMode;

to the InitLayout event method

When this method - void Editor_BeforeEnterEditMode(object sender, CancelEventArgs e) is called, I create a new BindableValueList & BindingSource. I wire up those two objects like this:
           UltraGridColumn ugc =ultraGrid.DisplayLayout.Bands[0].Columns[this.dataSet.dataTable.CLASS_IDColumn.ColumnName];

           var bvl = new BindableValueList();

            var bs = new BindingSource(components);

            bs.DataSource = this.dataSet;

            bs.DataMember = this.dataSet.dataTable.TableName;

            bs.Filter = "RETIRED = 'N'";

            bvl.DisplayMember = this.dataSet.dataTable.NAMEColumn.ColumnName;

            bvl.ValueMember = this.dataSet.dataTable.CLASS_IDColumn.ColumnName;

            bvl.SortStyle = ValueListSortStyle.Ascending;

            bvl.BindingContext = BindingContext;

            bvl.DataSource = bs;

            ugc.Style = ColumnStyle.DropDownList;            
            ugc.ValueList = bvl;

The problem is this: When the Editor_BeforeEnterEditMode completes, the value in the cell changes from the Name field value to the ClassId value. It only changes for an item that has a value of IS_RETIRED. It is as if I reversed the BindableValueList display and value member.

The overall goal here is to remove specific items from the dropdown list so user cannot select that value again.

For example I have a item that was already added to the grid that has a value of IS_RETIRED = 'Y'. I don't want to remove this value from the existing list of items in the grid, however I want to make sure that when user attempts to edit, items that have a value of IS_RETIRED = 'Y' are removed from the list so they cannot be selected.

Hope that makes sense, thanks for the input

Example