jQWidgets Forums

jQuery UI Widgets Forums Grid Clone grid row

This topic contains 4 replies, has 2 voices, and was last updated by  jb 9 years, 10 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • Clone grid row #73412

    jb
    Participant

    Hello,
    I want to add a button next to my grid that’ll clone the selected row into a new row in the same grid. This new row (child) has to be identical to it’s originating row (parent) but also independent, to allow users to change it’s content without affecting the parent row.
    Works well until I save/refresh the data. Seems like the parent and child records share the same “uid”, so all changes performed on the “child” are also applied in the parent record (and vice versa)
    fiddle
    I modified your “addrow” fiddle to display what I mean.
    Steps:
    1)Check the uid of any row by selecting it and then hit “Info”
    2)Clone this row by hitting “Clone Row”
    3)Check the uid of the original and cloned rows (they will be identical, and the parent row will use the child’s uid)
    4)Modify content of a cell of the child (cloned) record, such as the last name
    5)Add a new row or clone another row to make the renedring to be refreshed, you’ll see all clones to then be alike.

    Note my grid uses binded xml data, in case it makes a difference in your recommended fix.

    jb

    Clone grid row #73430

    Peter Stoev
    Keymaster

    Hi jb,

    Your cloning logic is wrong. You should create a new Object and set the object’s members to the datafields values only.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Clone grid row #73462

    jb
    Participant

    Thanks Peter,
    Would you mind pointing me to an example in the jqWidget documentation or quickly modify the fiddle to demonstrate what you mean?
    That would help me greatly, thanks!

    jb

    Clone grid row #73463

    Peter Stoev
    Keymaster

    Hi jb,

    The idea is: var row = {}; row.firstname = …, row.lastname = …., etc.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Clone grid row #73466

    jb
    Participant

    Thanks Peter, for the benefit of others, I enhanced my fiddle with this concept. Works like a charm.

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

You must be logged in to reply to this topic.