jQWidgets Forums

jQuery UI Widgets Forums Grid Maintain current row selection after refresh

This topic contains 1 reply, has 2 voices, and was last updated by  Hristo 6 years, 7 months ago.

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

  • Pietervk
    Participant

    I have the following grid initialisation:

    
     $("#jqxgrid").jqxGrid(
            {
                source: dataAdapter,
                width: StWidth,
                pageable: true,
                pagesize: pagesize,
                sortable: true,
                filterable: true,
                enabletooltips: true,
                selectionmode: 'multiplerowsextended',
                columnsresize: true,
                columnsautoresize: true,
                pagesizeoptions: ['5', '10', '20', '30'],
                autoshowloadelement: false,
                autoheight: true,
                theme: 'energyblue',
                columns: StColumns,
                virtualmode: true,
                rendergridrows: function (params) {
                    return params.data;
                }
    
            })

    I am using SignalR to update data in real time. Updating the cells goes well. After deletion or insertion of a row by someone else, I would like to update the grid. So I call

    
      $("#jqxgrid").jqxGrid({ source: dataAdapter });
         

    My question is, is it possible to restore the previous row selection after a refresh? (Taking in to account that the current row index is not necessarily the right index after the refresh.

    For example for single row selection, I can get the Id of the row:
    var id = $(‘#jqxgrid’).jqxGrid(‘getrowid’, selectedRow);
    But I am missing the setSelectedRowById.
    And even better would be if I can maintain the whole selection.

    Any suggestions would be welcome.


    Hristo
    Participant

    Hello Pietervk,

    You could use the getselectedrowindexes method of the jqxGrid to get selected rows. (it is possible to use save/load state)
    Also, you could bind to the rowselect event and to achieve more data from there.

    I would like to mention if the source is bound to correct it is not necessary to refresh the jqxGrid on that way – to set the “source: dataAdapter” again.
    In this case, you could use updateboundata method when you want to update the jqxGrid.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

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

You must be logged in to reply to this topic.