jQWidgets Forums

jQuery UI Widgets Forums Grid Export failing in virtual mode with pagination

This topic contains 4 replies, has 2 voices, and was last updated by  DM 11 years, 11 months ago.

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

  • DM
    Participant

    Hi,

    I have a problem with the data export. We’re using virtualmode, pagination and JSON data and the combination seems to cause a problem exporting any page other than page 1. This can be easily reproduced in the dataExport.htm sample.

    Add the following script references:

    Change the datatype in the source:
    datatype: “json”,

    Add the following grid options:
    pageable: true,
    virtualmode: true,
    rendergridrows: function (data) {
    return data.data;
    },

    ..then run the page. Skip to page 2 and then try the export. I’m getting an exception:

    Line: 7
    Error: Unable to get property ‘hasOwnProperty’ of undefined or null reference

    … which appears to be relate to the array of data. For JSON the grid code resets the lower bound of the array, so for a page size of 10, the internal array for page 2 has elements at index 10, 11, 12…etc. The export code looks like it assumes the index to start at 0.

    …or am I doing something wrong…?

    Thanks.


    Peter Stoev
    Keymaster

    Hi,

    It is not possible to Export the Grid in Virtual Mode because the Data is loaded on demand.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    DM
    Participant

    Hi,

    Ok…a little confused. I understand there’s a virtual mode where requests for data are made as the user scrolls through the grid, but here we’re doing server side pagination. We’ve retrieved our records for page (n) and they’re in the grid. There’s no more data to retrieve.

    Isn’t there a difference between a virtual mode with pagination (server side pagination) and a virtual mode without? I can understand the issue with data requests on demand but when it’s paginated there are no data requests on demand…

    Thanks.


    Peter Stoev
    Keymaster

    Hi,

    In Server Paging the data is loaded on demand, too and that happens when you change the page. It is the same like virtual scrolling, but instead of scrolling up and down, not you do it left and right, but you still load small chunks of data.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    DM
    Participant

    Hi Peter,

    So let’s assume that we’ve navigated to page 2, with a page size of 10 and therefore I get back an array of items with the indexes 10, 11, 12, 13, 14, 15, 16, 17, 18, 19. I then try to export this page and the export functionality eventually ends up in the exportContent function of jsqdata.export.js which has a for (;;) loop starting at 0 – and it fails. I’m guessing that if this was a forEach loop or started at the lowest array index, then it would work fine. My users would be able to export and print page n (I’m printing a grid by exporting to HTML and printing the output).

    At the end of the day, by the time the export code runs it’s already retrieved the data so that’s fine. It’s how the data is processed by the export that’s causing the error…

    function exportContent(exporter) {
    exporter.beginBody();
    for (var i = 0; i < data.length; i += 1) {
    exportRow(exporter, data[i], i);
    }
    exporter.endBody();
    }

    I think it's worth a look to see if it can be fixed. Otherwise I've got to disable printing and exporting for anything other than the first page.

    Regards,

    Alan Faux

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

You must be logged in to reply to this topic.