Author Topic: Problem editing new row  (Read 2505 times)

stevejacobsen

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 46
    • View Profile
Problem editing new row
« on: December 13, 2016, 10:08:58 am »
I have a button that calls a function to insert a record in my database, get the inserted record id and then insert the record in the grid with that id. But I'm not able to get to the next step of editing the record. The line with "editFirstCellInRow" returns an error:

grid.editFirstCellInRow is not a function

The row is getting created and it is getting past the "addClass" line. Do I need something else?



Quote
function service_add(grid)
{
    $.ajax({
        context: grid,
        dataType: 'text',
        url: "/utilities/ajax_add_service.php",
        success: function (data) {
            var id = data;
            var rowIndx = 0;

            today = today();

            $("#services_grid").pqGrid("addRow", {newRow: {id: id, service_date: today}, rowIndx: rowIndx, rowIndxPage: 0});

            grid.addClass({rowIndx: rowIndx, cls: 'pq-row-edit'});
 
            grid.editFirstCellInRow({rowIndx: rowIndx});

            //show the save button .
            var $tr = grid.getRow({rowIndx: rowIndx}),
                    $btn = $tr.find("#saveservice");

            $btn.button("option", {label: "Save", "icons": {primary: "ui-icon-check"}})
                    .unbind("click")
                    .click(function (evt) {
                        return service_save(rowIndx, grid);
                    })
                    .show();
        }
    });
}

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: Problem editing new row
« Reply #1 on: December 13, 2016, 10:29:59 am »
Please check the value of grid variable. It's supposed to be grid instance, not a jQuery object.

stevejacobsen

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 46
    • View Profile
Re: Problem editing new row
« Reply #2 on: December 13, 2016, 10:02:57 pm »
Yep, I had some errant code in the calling button. Now I'm just dealing with the next lines. The button is not initialized yet so I can't work with it. I'll play with it and see if I can get past that.

Thanks!
Steve