jQuery UI Widgets Forums Grid Grid push selected same rows to new grid

This topic contains 8 replies, has 2 voices, and was last updated by  Martin 6 years, 4 months ago.

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

  • dan123
    Participant

    Hi i have created this case where there are two grids, one grid has the custom checkbox selection (provided by jqwidgets team) where based on the selected rows i want to push or use addrow method to send the rows to the second grid.

    Issue: For some reason, only the first selected row is being added to the second grid. I am sure something wrong on the ‘clonerows’ function in my part, but not sure whats the reason.

    Expected output:
    Grid 1
    Selected rows 1, 2, and 4
    Click on ‘Push Rows’

    Grid 2 will have rows 1,2, and 4

    Here is my example:
    https://jsfiddle.net/2ed1znrc/13/

    Side note->I also did wanted to verify, if there was a way to compare the data between two grids. For instance after the selected rows have been added to second grid, is there a way to do a check/validation if i selected the same rows on grid 1 again and did push rows?


    Martin
    Participant

    Hello dan123,

    The issue is that you are ‘return’-ing the child in the for-loop in “clonerows”, which exits the function on the first iteration.

    I have updated your Example.

    Best Regards,
    Martin

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


    dan123
    Participant

    Hi Martin

    Is there was a way to compare the data between two grids. For instance after the selected rows have been added to second grid, is there a way to do a check/validation to restrict the ‘Push rows’ button click if i selected the same rows on grid 1 again?

    Other thing was, when i did try your example (thanks for that) it was adding ‘Test 1’ row twice.


    dan123
    Participant

    The ‘Test 1’ showed twice whenever i did select all.


    Martin
    Participant

    Hello dan123,

    You can bind to the rowselect event of the first grid to get the selected rows and then
    compare them with those of the second grid.

    Here is an Example.

    I have also fixed the duplicated adding of ‘Test1’ by adding the following check inside ‘clonerows’ function:
    if (selectedrowindexes[i] == undefined) continue;

    Best Regards,
    Martin

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


    dan123
    Participant

    Hi Martin,

    So i put the selected rows logic in the clonerowbutton click event that will present an alert if there are any duplicates and prevent adding of rows. But some reason, the its not detecting the matching records, i am sure something is wrong with the if statement i used. Much appreciated if any help to help defect this

    Example:
    https://jsfiddle.net/2q8jLud5/2/


    Martin
    Participant

    Hello dan123,

    I see that in the example that you have sent you are comparing an object with a string, so it always returns false.
    Instead, you should compare the properties of the objects.
    I have updated your Example.

    Best Regards,
    Martin

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


    dan123
    Participant

    Hello Martin
    So in your example, when i selected ‘Test 1 and Test 2’, clicked on Push rows. It added to the second grid that is good. So after i unselected rows in grid 1, and now i want to select row ‘Test 3’, clicked Push rows and it seems like its alerting ad duplicate message even if ‘Test 3’ record is not on grid 3. Same case for if i selected even ‘Test 4 to 6’


    Martin
    Participant

    Hello dan123,

    I have update the Example, again.
    Please, take a look.

    Best Regards,
    Martin

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

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

You must be logged in to reply to this topic.