When restoring the layout of a grid out of a stream / registry the current filter is placed in the filter panel, but NOT in the autofilter row.
NOTE:
- All is working fine when entering a text in the autofilter row, so that the filter criteria is "like"
- Nothing is displayed when selecting a value from the filter drop down list
Workaround
Save/restore the AutoFilterRow's values via events. Here is the necessary code for the GridLookUp in-place editor:
using DevExpress.XtraEditors; using DevExpress.XtraGrid; using DevExpress.XtraGrid.Columns; using DevExpress.XtraGrid.Views.Grid; ArrayList filterList; bool isRestoringFilter = false; private void repositoryItemGridLookUpEdit1View_ColumnFilterChanged(object sender, EventArgs e) { GridView lookupView = sender as GridView; if(isRestoringFilter || lookupView.FocusedRowHandle != GridControl.AutoFilterRowHandle) return; filterList = new ArrayList(); foreach(GridColumn column in lookupView.Columns) { object filter = lookupView.GetRowCellValue(GridControl.AutoFilterRowHandle, column.FieldName); if(filter != null) { ColumnAutoFilterInfo info = new ColumnAutoFilterInfo(); info.FieldName = column.FieldName; info.Filter = filter; filterList.Add(info); } } } private void repositoryItemGridLookUpEdit1_Popup(object sender, EventArgs e) { if(filterList == null || filterList.Count == 0) return; isRestoringFilter = true; GridLookUpEdit editor = (GridLookUpEdit)sender; GridView lookupView = editor.Properties.View; lookupView.FocusedRowHandle = GridControl.AutoFilterRowHandle; foreach(ColumnAutoFilterInfo info in filterList) lookupView.SetRowCellValue(GridControl.AutoFilterRowHandle, info.FieldName, info.Filter); isRestoringFilter = false; } public class ColumnAutoFilterInfo { public string FieldName; public object Filter; }
Hello Georg,
Please add this code line to the entry point of your application to enable this feature in DXperience v8.1.1 or higher:
static void Main() { GridView.GuessAutoFilterRowValuesFromFilterAfterRestoreLayout = true;
If we get positive feedback on this change, we'll make this feature permanent in DXperience v2008 vol 2.
Thanks,
Nick