Author Topic: Inline Editing  (Read 4608 times)

lgauton

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 44
    • View Profile
Inline Editing
« on: March 05, 2015, 06:44:44 pm »
Hi I have a grid with inline editing and noticed that what was working correctly under 2.0.4 now doesn't under 2.3.0. - my update function is

        function update(rowIndx, $grid) {
            if (!$grid.pqGrid("saveEditCell")) {
                return false;
            }
            var rowData = $grid.pqGrid("getRowData", { rowIndx: rowIndx }),
                recIndx = $grid.pqGrid("option", "dataModel.recIndx"),
                type;

            var isValid = $grid.pqGrid("isValid", { rowData: rowData }).valid;
            if (!isValid) {
                return false;
            }

            var isDirty = $grid.pqGrid("isDirty");
            if (isDirty) {

                if (rowData[recIndx] == null) {
                    //add record.
                    type = 'add';

                }
                else {
                    //update record.
                    type = 'update';

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

                $grid.commit({ type: type, rows: [rowData] });
                $grid.refreshRow({ rowIndx: rowIndx });


            }
            else {
                $grid.quitEditMode();
                $grid.removeClass({ rowIndx: rowIndx, cls: 'pq-row-edit' });
                $grid.refreshRow({ rowIndx: rowIndx });
            }
        }

This statement always fails

 if (!$grid.pqGrid("saveEditCell")) {
                return false;
            }

and if I bypass all appears to work but get left with display of Update, Cancel buttons rather than Edit, Delete

Any ideas?

lgauton

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 44
    • View Profile
Re: Inline Editing
« Reply #1 on: March 05, 2015, 06:52:04 pm »
In above I mean't to say is 'This statement always returns 'false'

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6263
    • View Profile
Re: Inline Editing
« Reply #2 on: March 05, 2015, 07:04:09 pm »
Please use below to exclude null, == would also work.

if ($grid.pqGrid("saveEditCell") === false ) {
    return false;
}

lgauton

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 44
    • View Profile
Re: Inline Editing
« Reply #3 on: March 06, 2015, 02:01:07 pm »
Hi Thanks that fixed the validation issue, but I still have a problem with the Edit, Delete -> Update, Cancel buttons
going to edit mode is Ok, but clicking on Update button does not fully complete and re-display the Edit, Delete buttons - I'm left with Update, Cancel

Any ideas on that

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6263
    • View Profile
Re: Inline Editing
« Reply #4 on: March 06, 2015, 03:29:23 pm »
That require you to listen to both refresh and refreshRow events.

//use refresh & refreshRow events to display jQueryUI buttons and bind events.
        $grid.on('pqgridrefresh pqgridrefreshrow', function () {

http://paramquery.com/pro/demos/editing line 260

lgauton

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 44
    • View Profile
Re: Inline Editing
« Reply #5 on: March 06, 2015, 07:50:05 pm »
Hi I have set $grid.on('pqgridrefresh pqgridrefreshrow', function () {

But still get same problem

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6263
    • View Profile
Re: Inline Editing
« Reply #6 on: March 06, 2015, 08:17:07 pm »
methods invocation syntax is incorrect in your update function.

 $grid.quitEditMode(); //incorrect, same for removeClass, commit, refreshRow, etc

Code: [Select]
$grid.pqGrid('quitEditMode');  //correct
 
or
 
 var grid = $grid.pqGrid('getInstance').grid;
 grid.pqGrid('quitEditMode');  //correct
« Last Edit: March 06, 2015, 08:19:59 pm by paramquery »

lgauton

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 44
    • View Profile
Re: Inline Editing
« Reply #7 on: March 06, 2015, 09:15:33 pm »
Hi Thanks - I did notice that which helped - but finally resolved by adding this statement after commit, in update function
$grid.pqGrid("quitEditMode")
                        .pqGrid("removeClass", { rowIndx: rowIndx, cls: 'pq-row-edit' })
                        .pqGrid("rollback");
now works as previously under 2.0.4