ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: Balaji on November 18, 2016, 05:50:05 pm

Title: getInstance Method inside colModel render callback is not working in 3.3 version
Post by: Balaji on November 18, 2016, 05:50:05 pm
Hi

Earlier I have used this code while using 2.x version. and Now I upgraded to 3.3 version. I am using getInstance Method of the grid in render function of the colModel. Now after upgrading , getInstance method is returning undefined.


Is this will work in 3.3 , how to handle?

                         {
                             title: "Open", dataType: "float", width: '95', resizable: false, dataIndx: "open", align: "right",
                             editable: function (ui) {
                                 return disablePlus(ui);
                             },
                             render: function (ui) {
                                 var grid = $(this).pqGrid('getInstance').grid
                                 if (grid.isEditableCell({ rowIndx: ui.rowIndx, dataIndx: 'open' }) == false && ui.rowIndx == 1) {
                                     grid.addClass({ rowIndx: ui.rowIndx, dataIndx: 'open', cls: 'blackcell' });
                                 }
                                 return (!isNaN(ui.cellData) && Number(ui.cellData) > 0) ? parseFloat(ui.cellData).toFixed(2) : "";
                             }
                         }
Title: Re: getInstance Method inside colModel render callback is not working in 3.3 version
Post by: paramvir on November 18, 2016, 07:05:51 pm
Context of callbacks is grid itself.

Please replace

Code: [Select]
var grid = $(this).pqGrid('getInstance').grid

with

Code: [Select]
var grid = this;
Title: Re: getInstance Method inside colModel render callback is not working in 3.3 version
Post by: Balaji on November 19, 2016, 01:12:59 pm
var Grid= this;
is working fine. I got the context.

But after that when i call the below method
 grid.addClass({ rowIndx: ui.rowIndx, dataIndx: 'open', cls: 'blackcell' });

it is showing,
cannot call methods on pqGrid prior to initialization; attempted to call method 'addClass'.

Please check am i right or not.
Title: Re: getInstance Method inside colModel render callback is not working in 3.3 version
Post by: Balaji on November 19, 2016, 02:43:11 pm
Hi,

Issue with addClass was solved. I was looking incorrect. Without any changes the same code is working. Thank you for the valuable support.

Thank you.