Pregunta

I want to set checkbox column in gridview. Following codes do that:

gridSettings.PreRender = (sender, e) =>
{
    MVCxGridView gridView = sender as MVCxGridView;
    for (int i = 0; i < gridView.VisibleRowCount; i++)
    {
        gridView.Selection.SetSelection(i, (bool)gridView.GetRowValues(i, "IsAssigned"));
    }
};

But I have about 1 million records, so grid view loading time is too long (more than 2 minutes). Because devexpress, loop all records, page by page to find selected rows (my collection is IQueryable type). If I dont try to set this column, devexpress use IQueryable list, so it fetchs only one paged data.

What can I do to loop only visible rows?

¿Fue útil?

Solución

I changed my codes like following, I get selectedrows with tempdata in controller.

gridSettings.PreRender = (sender, e) =>
{
    MVCxGridView gridView = sender as MVCxGridView;
    if ((gridView != null) && (ViewData["selectedRows"] != null))
    {
        int[] selectedRows = (int[])ViewData["selectedRows"];
        foreach (int key in selectedRows)
        {
             gridView.Selection.SelectRowByKey(key);
        }
    }
};    
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top