jQWidgets Forums

jQuery UI Widgets Forums Grid Grid; Filterng and Selection (Displayrows V SelectedRows)

Tagged: , ,

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

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

  • stevenmahony
    Participant

    Hi,

    I have applied a filter to my grid. I now want to select just these rows and get the list of selected rows objects.

    Essentially a method that functions like – GetDisplayRows_SelectedIndexs

    Regards
    Steven


    Peter Stoev
    Keymaster

    Hi Steven,

    To get the collection of rows displayed in the Grid, use the “getdisplayrows” method.

    // gets all rows loaded from the data source.
    var rows = $('#jqxGrid').jqxGrid('getdisplayrows');
    // gets the first displayed row.
    var rowData = rows[0];
    // gets the ID of the first displayed row.
    var rowID = rowData.uid;
    // gets the bound index of the first displayed row. The bound index is the row's index in the array returned by the "getboundrows" method.
    var boundIndex = rowdData.boundindex;

    The “getboundrows’ method is another useful method which returns all rows in the same order as they are in your data source The “getselectedrowindexes” method returns the selected collection and each index is a bound index.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/


    stevenmahony
    Participant

    Hi Peter,

    Yes I am using that method to get only the rows that are displayed (by applying a row date filter).

    I now want to select just these rows , I am using ‘selectallrows’ but this selects all rows in the dataadapter.

    var visibleRows = $(“#jqxgrid”).jqxGrid(‘getdisplayrows’); [5,000 rows]
    var selectedRows = $(“#jqxgrid”).jqxGrid(‘getselectedrowindexes’); [10,000 rows] (users sees 5,000 highlighted rows in grid, even thou 10,000 are selected.

    I now want to pass the 5,000 rows to a method and update the database. Works fine because I can get the id I required from the objects in the displayrows data., but if I want to un-select any of the display rows and then pass the 4,999 rows to the method I still have 5,000 displayrows and I’m not sure how to remove the 1 rows from the getdisplayrows object and pass it to the database (without some javascript array matching)

    So what I am looking for is if there is a method (or combination of methids) that will get the selected indexes of the selected displayed rows in the grid?

    Thanks
    Steven


    Peter Stoev
    Keymaster

    Hi Steven,

    I am afraid that there is no such built in method. Each visible row as shown in the code I sent you has a “boundindex” member and each item in the “getselectedrowindexes” is a bound index, too. I suppose that you can make some loops with matching to evaluate which selected items are displayed.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

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

You must be logged in to reply to this topic.