Author Topic: getInstance Method inside colModel render callback is not working in 3.3 version  (Read 2627 times)

Balaji

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 4
    • View Profile
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) : "";
                             }
                         }

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Context of callbacks is grid itself.

Please replace

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

with

Code: [Select]
var grid = this;

Balaji

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 4
    • View Profile
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.

Balaji

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 4
    • View Profile
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.