jQWidgets Forums

jQuery UI Widgets Forums Grid How to set the return data to grid in virtualmode?

This topic contains 2 replies, has 2 voices, and was last updated by  yangtsecxf 9 years, 9 months ago.

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

  • yangtsecxf
    Participant

    hi, I have a question about render grid in virtualmode, here is part of my code

    var GetTransients = function (startindex, endindex) {
    var data = {};
    $.get(‘/GetTransients’,{startindex:startindex, endindex:endindex}, function(rtdata){
    if(null != rtdata){
    data = JSON.parse(rtdata);
    return data;
    }
    })

    return data;
    }
    var rendergridrows = function (params) {
    var data = GetTransients(params.startindex, params.endindex);
    return data;
    }
    $(“#jqxgrid”).jqxGrid({
    width: ‘99%’,
    height: ‘95%’,
    filterable: true,
    pageable: true,
    pagermode: “simple”,
    pagesize: 30,
    pagerbuttonscount: 10,
    virtualmode: true,
    rendergridrows: rendergridrows,

    I can get the data from server by “$.get(‘/GetTransients’,{startindex:startindex, endindex:endindex}”, but the grid still no data to show.How to set the return data “var jObjs = JSON.parse(rtdata);” to grid? Thanks.


    Vladimir
    Participant

    Hello yangtsecxf,

    You can check this demo for a working example of jqxGrid used in virtual mode.

    In your code you seem to lack the source option for your grid, so it doesn’t know how many total rows it should display. In the provided fiddle you can see it is set to a dataAdapter linked to an empty object array with totalRecords option specified.

    Best Regards,
    Vladimir

    jQWidgets Team
    http://www.jqwidgets.com


    yangtsecxf
    Participant

    1.I have pass the total count when render the page, it is “var transientCnt = <%-: transientCnt %>;”.
    2.I have checked similar demo, the demo is different from my situation, the demo’s data is already exsit after page render finish, just get it by random function, so it is synchronous, my situation is after page rendered, when click the page, ajax(get) data by ‘startindex’ and ‘endindex’ which come from ‘rendergridrows’, so it is asynchronous, I wondered is how to set the asynchronous data to grid. Thanks.

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

You must be logged in to reply to this topic.