ParamQuery grid support forum
General Category => Bug Report => Topic started by: nuno.nogueira on March 10, 2014, 05:51:10 pm
-
I get the error:
Uncaught TypeError: Cannot read property 'pq_detail' of undefined
When refreshing the data in the table.
It happens when the table is empty: I have no idea why this error is now being displayed now but it seems the table isn't properly refreshed when the table is empty.
Thanks for helping!
-
I should add that when deleting the last row of the table I get:
Uncaught TypeError: Cannot read property '0' of undefined
-
Is it a master detail grid?
When refreshing the data in the table.
Which one? master or detail
when deleting the last row of the table I get:
master or detail?
could you include a little test case?
-
It is both (when deleting the last row of detail, you delete also the last row of the master).
In my application, I have new data per month (controlled with the links at the bottom "somar" and "subtrair".
When opening an empty month (for example Abril-2014) the table doesn't refresh and the error starts breaking the code.
Have a look at:
[url=http://www.portal-gestao.com/or
-
Your url is broken.
Have you copied the code to expand first row from the demo. You should check the length of data before expanding the row.
if (data && data.length) {
data[0]['pq_detail'] = { 'show': true };
}
-
Hi,
The link isn't broken, but this forum is cutting part of the text.
You may see the example here: http://www.portal-gestao.com/or%C3%A7amento.html# (http://www.portal-gestao.com/or%C3%A7amento.html#)
Go to an empty grid, clicking in "Somar" at the bottom and see the error.
I am not expading any rows.
This error is breaking the code,
-
I can see the error.
What does somar do. It looks like it refreshes the whole grid. What is the code of this function.
-
It adds a month and refreshes the grid with the data of that month.
Subtrair deducts a month.
Here's the function being called:
[code]function mudaMes(acrescenta) {
var dataCorrente = new Date(hoje.getFullYear(), hoje.getMonth() + acrescenta, 1);
$('#mescorrente').html("Este m
-
In attachment you may see the code:
-
your issue may be related to the wrong way you are refreshing the grid. You should not pass the whole constructor object while refreshing the grid.
Instead of that just pass the postData option and call refreshDataAndView
-
It is related with the month change event, it seems.
I now get the error:
Uncaught TypeError: Cannot read property '3' of undefined
When changing the month to April.
This is the code I'm now using:
var obj = {
dataModel: {
postData: {
mesSelect: mes,
anoSelect: ano
}
};
var $objOrcamento = $("#tabela").pqGrid(obj);
$objOrcamento.pqGrid("refreshDataAndView");
}
Also tried:
$.ajax($.extend({}, ajaxObj, {
data: {
mesSelect: mes,
anoSelect: ano
}
}));
But it tells me that ajaxObj is not defined, although I moved it out of any functions.
-
I'm afraid to say it's still incorrect way to pass options to the grid.
Please go through the documentation on how to pass postData after initialization.
http://paramquery.com/pro/api#option-dataModel-postData
-
I also tried:
$( "#tabela" ).pqGrid( "option", "dataModel.postData", {mesSelect:mes, anoSelect:ano});
Which returns exactly the same error:
Uncaught TypeError: Cannot read property '3' of undefined
Although the request is sent to the server and returns:
{"data":[]}
Because there is No data for this month (April), which is correct.
The error is thrown only when the table is empty!
-
Hello,
Can you help with this? How am I supposed to refresh the table?
$( "#tabela" ).pqGrid( "option", "dataModel.postData", {mesSelect:mes, anoSelect:ano});
Which returns an empty data JSON file. OK.
And:
$("#tabela").pqGrid("refresh");
Or:
$("#tabela").pqGrid("refreshDataAndView");
That does not refresh the main grid and returns the mentioned error in the details'.
-
Could you use dev version of js and find out the line where exactly its throwing the error.
-
Sure, it is on lines 653 and 136.
Note: You may see the error at: http://www.portal-gestao.com/or%C3%A7amento.html# (http://www.portal-gestao.com/or%C3%A7amento.html#)
If an empty month is loaded from scratch, no problem, the error is thrown only when changes are made to the data model.
Thanks for your support!
-
your dev version is minified. It's difficult to see where is the issue. Could you use the dev file without any modification.
and which version are you using 2.0.3 or 2.0.4
-
Pls see attached, this forum is a bit complicated...
-
Hi,
Did you have the chance to look into this?
Everything else seems to be working, except refreshing an empty table.
Thanks for your support!
-
The issue couldn't be reproduced at my end.
You have to include all js files in non minified format if you want me to take a look into what's going on.
-
Hi,
Here they are:
http://portal-gestao.com/budget/orcamento.js (http://portal-gestao.com/budget/orcamento.js)
You may see the page at:
http://www.portal-gestao.com/or%C3%A7amento.html (http://www.portal-gestao.com/or%C3%A7amento.html)
This is most likely a bug, so I'd like to have you looking into it.
Thanks!
-
The scripts included inside the page are still minified.
Please include non - minified scripts inside the page and kindly mention detailed steps to reproduce the issue/issues.
-
Hello,
We have disabled mod_pagespeed, I think the scripts are non-minified now.
In addition to the above scripts, the month-changer script should also be considered:
http://www.portal-gestao.com/budget/mescorrente.js (http://www.portal-gestao.com/budget/mescorrente.js)
To reproduce the error, simply go to:
http://www.portal-gestao.com/or%C3%A7amento.html
And click "somar" at the bottom to go to the following month (april)
You'll see that there's no data but the main grid will not update. If you try to expand the sub-grid, you'll get the error.
The desired result should be an empty table with the message "no rows..."
Thanks!
-
Hello,
Were you able to reproduce the error?
I'm on a bit of time pressure here to close this project, will it be possible to fix the problem?
If it is ok, I'll minify the files again. Please advise.
Thanks
-
Nuno
You would get the fix by Tuesday. It would be helpful ( just in case ) if you can keep the files unminified until this weekend.
-
Ok, thanks a lot, I'll leave the files unminified.
But, the link is now:
http://ebudget.portal-gestao.com/app (http://ebudget.portal-gestao.com/app)
Basically, the same stuff..
-
Nuno
As a workaround, please modify your getData method.
getData: function (dataJSON) {
var data = dataJSON.data;
if(!data || !data.length){
var that=$(this).pqGrid("getThis").that;
that.dataGM=null;
}
return {
curPage: dataJSON.curPage,
totalRecords: dataJSON.totalRecords,
data: data
};
}
-
Hi,
That has fixed it, thanks!
:D