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 methodWhen 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
Estimated as I can do the following: in a form I have a ultracomboeditor I want when selecting a stored value process is executed and the result is loaded into a UltraGrid. Thanks in advance
Hi,
That should work, as long as the SelectedRow is up-to-date before this code is called.
Another approach would be to trap the FilterRow event. This event allows you to override the filtering on a row-by-row basis. So you could handle the event and compare the grid cell's value with the ValueMember cell in the DropDown and if they are the same, set e.RowFilteredOut to false to force that row to show. If your approach is working, though, it's probably better.
Sometimes I answer my own question, this is one of those times :)I get the selectedRecord from the UltraDropdown datasource and check if that record IS_RETIRED='Y'. If so I add this filter with an Or operator:if (selectedRowIsRetired != null) { columnFiltersRetiredFlag.FilterConditions.Remove(filterByIsRetiredCondition); columnFiltersClassId.FilterConditions.Add(filterByClassIdCondition); columnFiltersRetiredFlag.FilterConditions.Add(filterByIsRetiredCondition); vl.DisplayLayout.Bands[0].ColumnFilters.LogicalOperator = FilterLogicalOperator.Or; }
Amost got this wrapped but have one more question. When I'm doing my filters how do exclude my selectedItem from the filter.For example, user selects Item A which is a retired record.This filter will remove that record so when the user sees the dropdown, that selected record will not be therevar columnFiltersRetiredFlag = vl.DisplayLayout.Bands[0].ColumnFilters["IS_RETIRED"];var filterCondition = new FilterCondition(ugc, FilterComparisionOperator.Equals, 'N'); columnFiltersRetiredFlag.FilterConditions.Add(filterCondition);The end goal is to always have the selected item available for selection in the dropdown list, all the rest of the records that have value IS_RETIRED='Y" should be filtered out.Thanks for the insight
Perfect, I was hiding the column using the visual editor for the grid which works for the grid, was unsure how to do it for my add new item dropdown.Thanks again, those docs will prove helpful I'm sure.