jQuery UI Widgets Forums Grid getdisplayrows returning all grid rows instead of the displayed ones

Tagged: ,

This topic contains 7 replies, has 3 voices, and was last updated by  Peter Stoev 13 years ago.

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

  • Rodolfo
    Member

    Hi, first of all, thanks for the great scripts! I’m doing some integration with WordPress  and it’s amazing to create a grid and do live updates on the database.

    I’m experiencing an unexpected result for getdisplayrows, it’s returning all the rows instead of the displayed ones.

    This is the collapse/expand button code:

    $("#collapseGrid").jqxButton({ width: 140, theme: theme });
    $("#collapseGrid").click(function () 
    {
        var rows = $('#jqxgrid').jqxGrid('getdisplayrows');
        console.log(rows.length); // This shows 11, instead of the 5 displayed
        var mode = 'hiderowdetails';
        if( $('div[role="rowgroup"]:first').css('display') != 'block')
            mode = 'showrowdetails';
        $("#jqxgrid").jqxGrid('beginupdate');
        for( i=0; i<rows.length; i++) 
        {
            $('#jqxgrid').jqxGrid(mode, i);
        }
        $("#jqxgrid").jqxGrid('endupdate');
    });
    

    And here, the Grid config. jdata is being passed through wp_localize_script. And pagesize and pagesizeoptions are working ok, I tried to hardcode the values, but the result is the same:

    
    width: '100%',
    editable: true,
    pageable: true,
    autorowheight: true,
    autoheight: true,
    enablemousewheel: false,
    pagesize: parseInt(jdata.per_page),
    pagesizeoptions: jdata.page_options,
    showstatusbar: true,
    statusbarheight: 30,
    altrows: true,
    columnsresize: true,
    enabletooltips: true,
    showtoolbar: true,
    toolbarheight: 40,
    rendertoolbar: rendertoolbar,
    showaggregates: true,
    theme: theme,
    rowdetails: true,
    sortable: true,
    selectionmode: 'none',
    rowdetailstemplate: { rowdetails: "
    ", rowdetailsheight: 480 }, ready: jgrid_on_ready, initrowdetails: initrowdetails, source: dataAdapter, columns: [ { text: jdata.localize.field_id, datafield: 'ID', width: '10%', editable: false }, { text: jdata.localize.field_name, datafield: 'name', width: '20%', editable: false }, { text: jdata.localize.field_img, datafield: 'img', width: '20%', cellsrenderer: imagerenderer, editable: false }, { text: jdata.localize.field_notes, datafield: 'notes', width: '40%', editable: true }, { text: jdata.localize.field_choose, datafield: 'select', columntype: 'checkbox', width: '7%', aggregates: [ {'Total': function(aggregatedValue, currentValue) { if (currentValue) { return aggregatedValue + 1; } return aggregatedValue; }}] } ]

    Peter Stoev
    Keymaster

    Hi,

    “getdisplayrows” returns all rows loaded and displayed in the Grid. Depending on the pagesize and pagenum, you may filter the returned Array.

    Best Regards,
    Peter Stoev


    Rodolfo
    Member

    Hi, Peter,
    but what’s the difference with getrows then?

    In the docs for getdisplayrows: Gets all rows that are currently displayed in the Grid.
    And getrows: Get all rows.

    thanks!


    Peter Stoev
    Keymaster

    Hi,

    There is no difference. The one method will be removed, but is kept for backward compatibility.

    Best Regards,
    Peter Stoev


    cosostones
    Participant

    Hi,

    Whe I am testing the two methods, I can see big differences :
    – getrows : return rows as they where in the source of data of the grid
    – getdisplayrows : return rows as they are currently displayed (sorted, filtered) and some “rows” are in fact groups if some groups have been selected. thats why there is not always the same number of rows returned by the 2 methods.

    Can Technical Support confirm this?

    Thanks.


    Peter Stoev
    Keymaster

    Hi,

    “getrows” does not return the rows as they where in the data source if Filtering or Sorting is applied.

    Best Regards,
    Peter Stoev


    cosostones
    Participant

    Hi Peter,

    Ok for filters and sorting applied.

    And for groups (and sub-groups). Do you know if “getrows” should show them also ?

    Thanks.


    Peter Stoev
    Keymaster

    Hi,

    Actually you are right and I am wrong. The “getdisplayrows” includes all displayed rows including the Groups headers. “getrows” includes only the rows.

    Best Regards,
    Peter Stoev

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

You must be logged in to reply to this topic.