scottcm
13 years agoNew Contributor
Filtering a DevExpress XtraGrid's PopupList column
Below are 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
}
}
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
}
}