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
20
Load on demand functionality
posted

Hi, 

I am looking into ways to improve performance of an ultragrid when it comes to handling large databases.

Data is coming from a stored procedure and the grid is bound to a datatable via an adapter.

I'm new to Infragistic tools and I don't understand how to implement the UltraDataSource to achieve the load-on-demand functionality in the app.

I downloaded the sample for the virtual mode but I wasn't able to make it work with data from a database.

Can you please tell me the right procedure?

Thank you in advance,

Cécile.

Parents
No Data
Reply
  • 1149
    Suggested Answer
    posted

     

    Hi Cécile,

    I'm working on the Load-On-Demand too for the first time in these days.
    The point that stay at the base of this way to load data is that the grid is not directly binded to any datasource.
    As you have probably seen in the Virtual Mode sample, you can create an UltraDataSource and than bind the grid to it

    UltraDataSource myUDS = new UltraDataSource();
    grid.DataSource = myUDS;

    But you will not bind the UDS to anything. Setting the load style of the grid to "Load on demand"

    grid.DisplayLayout.LoadStyle = LoadStyle.LoadOnDemand;

    the grid will ask data only when it needs them, like e.g. when a row comes into view.
    The binded UDS listens to the grid and fires some events according, particularly when the grid need to show a certain cell the UDS will fire the event "CellDataRequest".

    Subscribing this event you can provide the data at real time; in the Virtual Mode sample the data is generated, because is just a random number, but in your subscription you can insert the logic you need (for example the logic that get data from the DataBase).

    The only two things you have to initialize before are:

    1) set the number of rows the grid will have (in your case probably getting this value with a proper SQL query that return the count)

    myUDS.Rows.SetCount( myIntValue );

    2) you need to initialize the columns you want to show in the grid (remember the grid is binded to the
    UDS, but this one is not binded to anything)

    myUDS.Band.Columns.Add("Column 1", typeof(string));
    myUDS.Band.Columns.Add("Column 2", typeof(int));
    myUDS.Band.Columns.Add("Column 3", typeof(DateTime));
    etc...


    Regards
    Gianni

    As a sidenote: in order to optimize performance a direct access to the DB any times the event "CellDataRequest" is fired, is probably not a good idea, you have to invent some kind of caching, getting chunks of data in memory and then ask the DataBase only when a new chunk is necessary, like a sort of pagination.

Children
No Data