如何在DevExpress ASPxGridView中按选定行过滤

时间:2011-04-06 17:11:16

标签: c# asp.net devexpress aspxgridview

我想做这样的事情

grid.ApplyFilter("[Selected] == \'true\'");

按网格中的选定行应用过滤器。

我要过滤的列是

        <dx:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0" Width="10px">
            <HeaderTemplate>                                                        
                <input type="checkbox" onclick="gvGridView.SelectAllRowsOnPage(this.checked);" />
            </HeaderTemplate>
        </dx:GridViewCommandColumn>

2 个答案:

答案 0 :(得分:0)

不支持此功能作为开箱即用功能。但是,我们刚刚创建了一个新示例,展示了如何完成此操作并将其发布到我们的网站上。这是它的链接:

How to filter selected / unselected ASPxGridView's DataRows

答案 1 :(得分:0)

private DataRow SelectRoW()
    {
        DataRow[] objDataRows = null;

            if (gridView1 == null || gridView1.SelectedRowsCount == 0)
            { return null; }//end if
            else
            {
                objDataRows = new DataRow[gridView1.SelectedRowsCount];
                for (int i = 0; i < gridView1.SelectedRowsCount; i++)
                {
                    objDataRows[i] = gridView1.GetDataRow(gridView1.GetSelectedRows()[i]);
                }//end for

                gridView1.BeginSort();
                try
                {
                    foreach (DataRow row in objDataRows)
                    {
                        return row;//return selected row.
                    }//end foreach
                }//end try
                finally
                {
                    objDataRows = null;
                    gridView1.EndSort();
                }//end finally


            }//end else

        return null;
    }//end SelectRoW