Contributions
Re: Filtering a DevExpress XtraGrid's PopupList column
I did see that code and it's the basis for the code I wrote. I ended up figuring out the problem, but there is more than 1 possible solution. The easiest solution if you have control over the applications source code is to change the XtraGrid to filter by display text rather than value. I didn't have that option so I created a check for the type of editor used by the column filter and based on that either used text or looked up the "Id" value of the selection. The code snippet ended up looking like this. column = GetGridColumn(grid, view, columnId); if (column["ColumnEdit"] != null && column["ColumnEdit"]["EditorTypeName"] == "PopupList") { filterValue = GetIdValueFromDataSource(column["ColumnEdit"]["DataSource"], displayText); } else if (column["ReadColumnEdit"]!=null && column["ReadColumnEdit"]["EditorTypeName"] == "PopupList") { filterValue = GetIdValueFromDataSource(column["ReadColumnEdit"]["DataSource"], displayText); } else { filterValue = displayText; } view["SetFilterRowValue"](column, filterValue);1.5KViews0likes0CommentsFiltering a DevExpress XtraGrid's PopupList column
Beloware simplified methods for setting a filter on a DevExpress XtraGrid column. The code works when the column filter is a textbox, but it doesn't work when the column is a PopupList. Any suggestions for how to handle that scenario? function SetFilter(xtraGrid, columnId, filterValue) { var column = GetColumn(xtraGrid, grid["DefaultView"], columnId); xtraGrid["DefaultView"]["SetFilterRowValue"](column, filterValue); } function GetColumn(grid, view, columnId) { var columns; var col; if (view == null) { view = grid["DefaultView"]; } columns = view["Columns"]; if (aqObject["GetVarType"](columnId) == varOleStr)// The column is specified by caption { for (var i=0; i<columns["Count"]; i++) { col = columns["Item_2"](i); if (col["Caption"]["OleValue"] == columnId) { return col;// Column found } } return null;// Column not found } else { return columns["Item_2"](columnId);//The column is specified by index } }23KViews0likes2Comments