Author Topic: Error after upgrading to 2.0.4  (Read 5071 times)

Leo F

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 21
    • View Profile
Error after upgrading to 2.0.4
« on: March 20, 2014, 11:52:51 pm »
I am seeing this error for any grid that has cells with data in them, and the grid fails to load/display properly.

TypeError: $td is undefined pqgrid.dev.js:4225

Briefly looking at the source it would indeed seem that $td is not being set to anything.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6263
    • View Profile
Re: Error after upgrading to 2.0.4
« Reply #1 on: March 21, 2014, 12:38:01 am »
Could you please provide an example implementation of a grid where you faced this error.

Leo F

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Error after upgrading to 2.0.4
« Reply #2 on: March 21, 2014, 01:55:57 am »
What specifically would you like to see?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6263
    • View Profile
Re: Error after upgrading to 2.0.4
« Reply #3 on: March 21, 2014, 08:02:55 am »
Your first message is not quite helpful to reproduce this error because I don't see this error anywhere. just need a small test case from you.

Thanks
« Last Edit: March 21, 2014, 08:11:34 am by paramquery »

Leo F

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Error after upgrading to 2.0.4
« Reply #4 on: March 21, 2014, 05:58:15 pm »
I've narrowed down the issue a bit.

I am calling a function in beforeTableView:

obj.beforeTableView = function (event, ui) {
      Validate();
};

Among other things it adds/removes classes on some cells like so:
     grid.Container.pqGrid("addClass", { rowIndx: rowIndx, dataIndx: column.dataIndx, cls: 'gridCellValidationFailed' });

When all the cells are 0 or null, no validations are run so the part of the function where classes are added/removed is not reached and that's why the error does not happen. However if there is data then the error happens.
Also if I load a blank grid successfully, and then update the underlying data, followed by:
     grid.Container.pqGrid('refreshDataAndView');
then everything works fine.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6263
    • View Profile
Re: Error after upgrading to 2.0.4
« Reply #5 on: March 21, 2014, 09:10:33 pm »
beforeTableView is not supposed to make changes in the view. It can be used only to update the data.

I'm not sure why do you want to add classes in this event, but if you do then make changes in the JSON data as shown in this demo

http://paramquery.com/pro/demos/row_styles

Leo F

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Error after upgrading to 2.0.4
« Reply #6 on: March 21, 2014, 09:23:36 pm »
I know I can adjust the JSON directly, but doesn't .pqGrid("addClass") do that?
Anyway this used to work fine in 2.0.3

What would be the correct event to use?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6263
    • View Profile
Re: Error after upgrading to 2.0.4
« Reply #7 on: March 21, 2014, 11:36:53 pm »
addClass make changes in the data and view.

Quote
What would be the correct event to use?

That depends upon what you are trying to achieve. If the data is static you can probably add classes during intialization or during the load event.

If your data changes ( enabled editing ) and your classes are dependent upon data then probably in the cellSave event.

Leo F

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Error after upgrading to 2.0.4
« Reply #8 on: March 21, 2014, 11:43:59 pm »
The data is editable, and these validations are client side only.
I am already running the Validate() function from the cellSave event, but I also need to run it when the grid is initially loaded.
Anyway I have moved it to the load event, it seems to work now.

Thanks.
« Last Edit: March 21, 2014, 11:49:20 pm by Leo F »