Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
120
Sorting with Load on Demand
posted

I have a grid setup to load partial data on demand.  The grid is working great and it fetches data as needed until all data is on the client.  Now I'm trying to implement sorting.  I have the sorting enabled and it tries to sort the grid but it only sorts the data that is currently in the grid instead of all the rows in the collection.  I probably have to sort the actual collection myself and rebind but I'm not sure where to do that.  Please let me know the best steps to implement sorting with a grid that partial loads?

 Thanks,

Eric

  • 167
    posted

    I got your problem. You need to override the default sorting and your function which inturn makes a call to database to get the new set of data.

    To make it work you need to set the SortingAlgorithmDefault to Custom and supply a sort implementation method delegate in the page's Init stage before the grid starts to do any data binding:

    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        UltraWebGrid1.DisplayLayout.SortingAlgorithmDefault = SortingAlgorithm.Custom;
        UltraWebGrid1.DisplayLayout.SortImplementation = new SortRowsCollection(SortRows);
    }

    Then you can put whatever logic you want into the method.

    public void SortRows(RowsCollection rows, int[ indices)
    {

    <your logic>

    return;
    }

    You need to register for onSortColumn event of Infragistics. In this event you need to add the below lines of code:

    e.Cancel = true;