Author Topic: Uncaught TypeError: Cannot read property 'pq_detail' of undefined  (Read 12119 times)

webifi

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 45
    • View Profile
I keep getting "Uncaught TypeError: Cannot read property 'pq_detail' of undefined" when trying to use "deleteRow" on a grid that uses detailModel. (The detailModel is yet another grid, but the error happens even if the detail hasn't been expanded.)  Seems to be failing in pqGrid's detachInitView method.

Is there something different I must do to delete rows in a grid using detailModel?
« Last Edit: February 03, 2015, 06:53:45 am by webifi »

webifi

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: Uncaught TypeError: Cannot read property 'pq_detail' of undefined
« Reply #1 on: February 03, 2015, 07:58:19 am »
Update:

Here's a jsfiddle showing the issue:
http://jsfiddle.net/gq47cxev/

And one with the details removed to show that the delete button works:
http://jsfiddle.net/gq47cxev/2/

(Note, the data sources for these jsfiddles use CORS proxy to load data from your server.  CORSproxy seems to be running slow today, so it may take a while for the data to load)

Update2:

Here are jsfiddles using yahoo's yql instead of corsproxy (corsproxy seems to be getting DDOS'd):

Showing the non-working deleteRow (has detail):
http://jsfiddle.net/g897xzqx/

And with detail removed (delete button works now):
http://jsfiddle.net/g897xzqx/1/
« Last Edit: February 03, 2015, 08:24:51 am by webifi »

webifi

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: Uncaught TypeError: Cannot read property 'pq_detail' of undefined
« Reply #2 on: February 03, 2015, 09:02:18 pm »
Having just purchased pqGrid (My app has integrated pqGrid far enough to the point where I'm committed to its use.), please consider the above a support request, and move to the appropriate forum -- if needed.


paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6282
    • View Profile
Re: Uncaught TypeError: Cannot read property 'pq_detail' of undefined
« Reply #3 on: February 03, 2015, 09:03:20 pm »
I haven't checked it all but I found a problem in your implementation:

Code: [Select]
$grid.on('pqgridrefresh', function(){
            var $mgrid = $(this);
            $mgrid.find('.delete_btn').click(function(){
                console.log("dele button pressed");
                    var $tr = $(this).closest('tr'),
                    rowIndx = $mgrid.pqGrid('getRowIndx',{
                        $tr:$tr
                    }).rowIndx;
                console.log("Deleteing row:"+rowIndx);
                $mgrid.pqGrid('deleteRow',{rowIndx:rowIndx});
            });
        });

$mgrid.find('.delete_btn') would also found the delete buttons of the detail grid. Correct way is to assign a unique class (e.g., btn_cls) to the buttons column of the outer grid.

selector would be $mgrid.find('.btn_cls .delete_btn');

Please correct it and any other similar problem and let me know your results.
« Last Edit: February 03, 2015, 09:06:51 pm by paramquery »

webifi

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: Uncaught TypeError: Cannot read property 'pq_detail' of undefined
« Reply #4 on: February 03, 2015, 09:13:37 pm »
See corrected jsfiddle:
http://jsfiddle.net/g897xzqx/2/

Still has the same problem.  (My actual code does bind each grid's buttons separately -- This jsfiddle is just a very simplified version of it, with the minimum needed to trigger the issue.)

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6282
    • View Profile
Re: Uncaught TypeError: Cannot read property 'pq_detail' of undefined
« Reply #5 on: February 03, 2015, 09:25:25 pm »
It still has the same implementation problem.

Code: [Select]
$grid.on('pqgridrefresh', function(){
            var $mgrid = $(this);
            $mgrid.find('.delete_btn1').click(function(){ //incorrect
                console.log("dele button pressed");
                    var $tr = $(this).closest('tr'),
                    rowIndx = $mgrid.pqGrid('getRowIndx',{
                        $tr:$tr
                    }).rowIndx;
                console.log("Deleteing row:"+rowIndx);
                $mgrid.pqGrid('deleteRow',{rowIndx:rowIndx});
            });
        });

webifi

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: Uncaught TypeError: Cannot read property 'pq_detail' of undefined
« Reply #6 on: February 03, 2015, 09:28:37 pm »
Where is the problem with that?

It selects ".delete_btn1".  class "delete_btn1" only exists in the topmost grid.  Others are "delete_btn" (note the missing "1"), so their buttons are never activated.   Click a delete on the topmost grid and you'll see the issue.

webifi

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: Uncaught TypeError: Cannot read property 'pq_detail' of undefined
« Reply #7 on: February 03, 2015, 09:35:59 pm »
Updated to unbind and re-bind the click event, in case the grid is refreshed:
http://jsfiddle.net/g897xzqx/3/

Still the same issue.

webifi

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: Uncaught TypeError: Cannot read property 'pq_detail' of undefined
« Reply #8 on: February 03, 2015, 09:52:42 pm »
Simplified ever further (only one detail deep, no delete button column on detail):
http://jsfiddle.net/g897xzqx/4/

Still the same issue.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6282
    • View Profile
Re: Uncaught TypeError: Cannot read property 'pq_detail' of undefined
« Reply #9 on: February 03, 2015, 09:59:22 pm »
yes, got it. I'm looking into it.

Thanks

webifi

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: Uncaught TypeError: Cannot read property 'pq_detail' of undefined
« Reply #10 on: February 04, 2015, 01:55:41 am »
Thanks.

Do you think this is a bug in pqGrid, or an issue with my use of it?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6282
    • View Profile
Re: Uncaught TypeError: Cannot read property 'pq_detail' of undefined
« Reply #11 on: February 04, 2015, 01:35:25 pm »
This is a bug ( or editing not supported/tested fully along with row details as of 2.3.0 ) and would be fixed in the next version.

If I come across any temporary workaround for this version, I would let you know.
« Last Edit: February 04, 2015, 01:44:31 pm by paramquery »

webifi

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: Uncaught TypeError: Cannot read property 'pq_detail' of undefined
« Reply #12 on: February 04, 2015, 07:26:13 pm »
Kind of a big issue for me.  Much of my UI depends on this functionality.

I anxiously await your solution.  Thanks.
« Last Edit: February 04, 2015, 07:28:04 pm by webifi »

webifi

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: Uncaught TypeError: Cannot read property 'pq_detail' of undefined
« Reply #13 on: February 09, 2015, 07:25:32 pm »
Any ETA for a new version of pqGrid that will fix this issue?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6282
    • View Profile
Re: Uncaught TypeError: Cannot read property 'pq_detail' of undefined
« Reply #14 on: February 09, 2015, 07:38:08 pm »
ETA for release is this week.