ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: webifi on February 03, 2015, 06:51:25 am

Title: Uncaught TypeError: Cannot read property 'pq_detail' of undefined
Post by: webifi on February 03, 2015, 06:51:25 am
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?
Title: Re: Uncaught TypeError: Cannot read property 'pq_detail' of undefined
Post by: webifi 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/
Title: Re: Uncaught TypeError: Cannot read property 'pq_detail' of undefined
Post by: webifi 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.

Title: Re: Uncaught TypeError: Cannot read property 'pq_detail' of undefined
Post by: paramvir 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.
Title: Re: Uncaught TypeError: Cannot read property 'pq_detail' of undefined
Post by: webifi 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.)
Title: Re: Uncaught TypeError: Cannot read property 'pq_detail' of undefined
Post by: paramvir 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});
            });
        });
Title: Re: Uncaught TypeError: Cannot read property 'pq_detail' of undefined
Post by: webifi 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.
Title: Re: Uncaught TypeError: Cannot read property 'pq_detail' of undefined
Post by: webifi 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.
Title: Re: Uncaught TypeError: Cannot read property 'pq_detail' of undefined
Post by: webifi 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.
Title: Re: Uncaught TypeError: Cannot read property 'pq_detail' of undefined
Post by: paramvir on February 03, 2015, 09:59:22 pm
yes, got it. I'm looking into it.

Thanks
Title: Re: Uncaught TypeError: Cannot read property 'pq_detail' of undefined
Post by: webifi 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?
Title: Re: Uncaught TypeError: Cannot read property 'pq_detail' of undefined
Post by: paramvir 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.
Title: Re: Uncaught TypeError: Cannot read property 'pq_detail' of undefined
Post by: webifi 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.
Title: Re: Uncaught TypeError: Cannot read property 'pq_detail' of undefined
Post by: webifi on February 09, 2015, 07:25:32 pm
Any ETA for a new version of pqGrid that will fix this issue?
Title: Re: Uncaught TypeError: Cannot read property 'pq_detail' of undefined
Post by: paramvir on February 09, 2015, 07:38:08 pm
ETA for release is this week.
Title: Re: Uncaught TypeError: Cannot read property 'pq_detail' of undefined
Post by: webifi on February 14, 2015, 04:33:41 am
Still planning on releasing the fix this week?
Title: Re: Uncaught TypeError: Cannot read property 'pq_detail' of undefined
Post by: paramvir on February 17, 2015, 10:35:51 pm
v2.4.0 has been released.