ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: lgauton on March 05, 2015, 06:44:44 pm

Title: Inline Editing
Post by: lgauton 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?
Title: Re: Inline Editing
Post by: lgauton on March 05, 2015, 06:52:04 pm
In above I mean't to say is 'This statement always returns 'false'
Title: Re: Inline Editing
Post by: paramvir on March 05, 2015, 07:04:09 pm
Please use below to exclude null, == would also work.

if ($grid.pqGrid("saveEditCell") === false ) {
    return false;
}
Title: Re: Inline Editing
Post by: lgauton 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
Title: Re: Inline Editing
Post by: paramvir 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
Title: Re: Inline Editing
Post by: lgauton on March 06, 2015, 07:50:05 pm
Hi I have set $grid.on('pqgridrefresh pqgridrefreshrow', function () {

But still get same problem
Title: Re: Inline Editing
Post by: paramvir 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
Title: Re: Inline Editing
Post by: lgauton 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