jQWidgets Forums

jQuery UI Widgets Forums Grid Possible to cache data with 'virtualmode'?

Tagged: 

This topic contains 5 replies, has 2 voices, and was last updated by  Peter Stoev 12 years, 6 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author

  • kennylouie
    Member

    We’re looking to use jqxGrid for a project to potentially display hundreds of thousands of rows. I managed to get the grid working in virtual mode however the issue we noticed so far is that anytime the grid is scrolled it makes a request to the server to load data whether it’s been loaded or not.

    For example, the grid loads and displays rows 1-20, we scroll down, some loading happens, good, we scroll back up and rows 1-20 are loaded again, not good.

    Is it possible to get previously loaded data to be cached?


    Peter Stoev
    Keymaster

    Hi kennylouie,

    Unfortunately, there’s no built-in caching in virtual mode. In virtual mode, the Grid requests for data when it needs to display it. When the view is changed, the old displayed data is cleared.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    kennylouie
    Member

    Before I dive into this too deeply into this do you think it would be possible for the grid to get data through a cache mechanism with the use of loadServerData method? Something that might look like this:

    loadServerData: function (serverdata, source, callback) {
    var recordData;
    if (myCache.loadRequired(serverdata.recordstartindex, serverdata.recordendindex)) {
    $.ajax({
    dataType: source.datatype,
    url: source.url,
    data: serverdata,
    success: function (data, status, xhr) {
    myCache.updateCache(data.rows, data.totalrows);
    }
    });
    }
    recordData = myCache.getData(serverdata.recordstartindex, serverdata.recordendindex);
    callback({ records: recordData, totalrecords: myCache.TotalRows });
    }

    I guess what I need to know before I dig into this is what is expected in the “records” property of the callback. Is that an array of expected objects to be displayed based on the serverdata record start/end index?


    Peter Stoev
    Keymaster

    Hi kennylouie,

    records is expected to be an Array of the records to be displayed in the Grid and in virtual mode it depends on the start/end index. Ex, in virtual scrolling mode, if the start index is 15 and end index is 25, records should return an array of rows between 15 and 25 like: records[15], records[16], ….

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    kennylouie
    Member

    Hi Peter,

    I can see what you mean having added a console.log to the .jqxGrid options:

    rendergridrows:function(obj)
    {
    console.log(obj.data);
    return obj.data;
    },

    Going by your example of start/end index of 15-25, the data being passed in is 25 items in length, with ‘undefined’ entries from indexes 0-13, and data objects from 14 – 24. Is this expected?

    Kenny


    Peter Stoev
    Keymaster

    Hi Kenny,

    The data being passed in the example is 10 items. You shouldn’t count on the ‘lenght’ property of an array because it does not return the number of items in the array.

    Example:

                var array = new Array();
    array[99] = "Item 1";
    alert(array.length);

    The alert in the above code displays 100, not 1.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.