jQuery UI Widgets Forums Grid Add row to Grid question

Tagged: ,

This topic contains 1 reply, has 1 voice, and was last updated by  Franco01 7 years, 10 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Add row to Grid question #86400

    Franco01
    Participant

    I want to add rows to my grid in the following code:

    addButton.click(function (event) {
                            var rows = $("#Grid").jqxGrid('getrows');
                            if (rows.length != 5) {
                                if (!addButton.jqxButton('disabled')) {
                                    var dat=null;
                                    // add new empty row.
                                    if (rows.length != 0) {
                                        var d = rows[rows.length - 1].Date;
                                        
                                        if (typeof (d) == "string") {
                                            var dat = new Date(d
                                                .substr(0, 4) +
                                                "-" +
                                                d.substr(5, 2) +
                                                "-" +
                                                d.substr(8, 2));
                                        } else {
                                            dat = d;
                                        }
                                        dat.setDate(dat.getDate() + 1);
                                    }
                                    $("#Grid").jqxGrid('addRow', null, { Date: dat });
                                }
                            }
                        });

    I would like to add 1 day to the previous rows Date value.
    It’s work perfectly for the first insert, but in the second, it’s change the first added row’s Date value too.

    Example:
    2016-05-04
    2016-05-05
    Click Add button
    2016-05-04
    2016-05-05
    2016-05-06
    Click Add button again
    2016-05-04
    2016-05-05
    2016-05-07
    2016-05-07

    Add row to Grid question #86401

    Franco01
    Participant

    I have manage to solved it.
    This line cause the problem:
    dat.setDate(dat.getDate() + 1);

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

You must be logged in to reply to this topic.