jQuery UI Widgets Forums Grid Finding all selected cells in the grid

Tagged: ,

This topic contains 9 replies, has 3 voices, and was last updated by  ragavsrini 5 years, 10 months ago.

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

  • amankejriwal
    Member

    Hi All,

    First i would like you to thank the jqxwidgets team for making the code freely available. It is a boon for developers like me 🙂

    I am able to generate the grid and have enabled the ‘multiplecellsextended’ selection mode.

    The issue is that I am not able to find all the selected cells. I simply want to know the column and row number of ALL the cells selected.

    I checked the code for the grid using firebug and did not find any ID associated with the cell DIV.

    Please help me resolve this issue!

    Thank You


    Peter Stoev
    Keymaster

    Hi amankejriwal,

    Thanks for writing.

    Regarding your question:

    To get the selected cells, you may use the Grid’s “getselectedcells” method which returns an Array of the selected cells.

    var cells = $('#grid').jqxGrid('getselectedcells');

    Each cell has rowindex and datafield fields. The rowindex is the row’s index and the datafield is the column’s datafield.

    Regarding the license terms and conditions, please take a look at: http://www.jqwidgets.com/license and EULA.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Finding all selected cells in the grid #16946

    amankejriwal
    Member

    Hi Peter,

    Thank you for your response!

    I wrote the following code:

    $(“#jqxgrid”).on(‘cellselect’, function (event) {
    var cells = $(“#jqxgrid”).jqxGrid(‘getselectedcells’, event.args.datafield);
    alert(cells);
    });

    This returns the following: [object Object]

    How can I see the contents of this object?

    Regards
    Aman

    Finding all selected cells in the grid #16947

    amankejriwal
    Member

    I changed the code to:

    $(“#jqxgrid”).on(‘cellselect’, function (event) {
    var cells = $(“#jqxgrid”).jqxGrid(‘getselectedcells’);
    alert(cells);
    });

    Now it is giving back all the selected cells as [object Object], [object Object], [object Object], ……..

    Again, how do i see the contents of these objects?

    Finding all selected cells in the grid #16963

    Peter Stoev
    Keymaster

    Hi amankejriwal,

    To get the cell’s value, you can use this:

    var rowindex = 0;
    var datafield = "firstname";
    var value = $("#grid").jqxGrid('getcellvalue', rowindex, datafield);

    Each object in the getselectedcells array have rowindex and datafield options and you can use them to retrieve the cell’s value.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    amankejriwal
    Member

    Hi Peter,

    Actually I am trying to ask if it is possible to get the datafields and rowindexes of ALL the selected cells in an array? Do we have a function for that?

    Also, is there a list of functions for the grid javascript that I can reference?

    Regards
    Aman


    Peter Stoev
    Keymaster

    Hi Aman,

    Yes, that is the “getselectedcells” method. It returns all selected cells as an Array. Each cell in the Array have rowindex and datafield.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    amankejriwal
    Member

    Hi Peter,

    I do get an array but am not able to access it’s contents.

    Any idea on how to do that?

    Regards
    Aman


    amankejriwal
    Member

    Hey Peter,

    I got it……thank you!!

    Regards
    Aman

    Finding all selected cells in the grid #103824

    ragavsrini
    Participant

    Hi amankejriwal,

    Could you please share code to find rowindex from selected cells.

    Thanks
    Srini

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

You must be logged in to reply to this topic.