Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
300
Add row by double clicking like the "Add new row" header
posted

Is it possible to double click the igGrid and call the "Add new row" event? Currently if you enable the add row functionality you get an "Add new row" header at the top of the grid. This will create a temp row on that header. I would like to be able to double click the grid, take the row data clicked, call the "Add new row" event and populate the temp row with the data from the double clicked row.

I have tried the add row api but this adds a new row to the end. I really just want to mimic the single click and populate the temp row.

Thanks,
Donnie 

Parents
No Data
Reply
  • 29417
    Offline posted

    Hello Donnie ,

     

    Thank you for posting in our forum.

     

    Generally you can force the grid to enter edit mode of the add row like this:

     

    $("#grid1").igGridUpdating("startAddRowEdit", e);

     

    So for example you could hook a double click event for each row and  get the double clicked row’s cell values. Then you can store them in a global variable  and set the in the editCellStarting event.

     

    For example on the rows rendered event you can  hook the double click event for each row of the grid and on double click get and store the values:

       var valueToPass = new Array();

            $(document).delegate("#grid1", "iggridrowsrendered", function (evt, ui) {

                var body = ui.tbody;

     

                for (var i = 0; i < ui.tbody[0].children.length; i++) {

                    $(ui.tbody[0].children[i]).dblclick(function (e) {

                        var row = this;

                        valueToPass = new Array();

                        for (var j = 0; j < this.cells.length; j++) {

                            valueToPass.push(this.cells[j].innerText);

                        }

                        valueToPass.reverse();

                        $("#grid1").igGridUpdating("startAddRowEdit", e);

     

     

     

                    })

                }

            });

     

    Then on editCellStarting set those values to the cells:

    editCellStarting: function (evt, ui) {

                            if (ui.rowAdding) {

                                ui.value = valueToPass.pop();

                            }

                        },                   

     

    Please refer to the attached sample and let me know if you’re trying to achieve something similar.

     

    Best Regards,

    Maya Kirova

    Developer Support Engineer II

    Infragistics, Inc.

    http://es.infragistics.com/support

     

    igGrid_AddRow.zip
Children
No Data