jQuery UI Widgets › Forums › Grid › Cannot read property 'uid' of undefined
This topic contains 20 replies, has 4 voices, and was last updated by Peter Stoev 10 years, 1 month ago.
-
Author
-
Whilst I cannot be sure that this error has arisen from this as my software is extremely large so it is hard to test everything before an update, however, as far as I can see, since updating to 3.5.0, I am receiving the following error when trying to change page on any of my grids:
Cannot read property ‘uid’ of undefined
I can probably sort this myself, so probably not beneficial to post up my code, I just need to know what this line of code is looking for?
Thanks in Advance
Hello Benji6996,
From the provided information we cannot find out what the error is or where to look for it. If you wish from us to test this, then please share a jsfiddle.net sample which demonstrates an erroenous behavior.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comIts not very easy to make a jsFiddle as the code is dynamic and dependant on certain libraries etc. Instead, I will post my code up, but if it is too detailed to go through then let me know and I will do my best to try and put together a jsFiddle…
I think it is likely that this issue is just due to me not having set a property in the grid definition that is njow required in 3.5.0, as this was working before, and now it isn’t working on not just one, but every single grid I have in my software.
// Create the localize object var localizationobj = { decimalseparator: '.', thousandsseparator: ',' }; // Prepare the response data var source = { url: '//api.website.net/data/', datatype: "json", datafields: [ { name: 'reference', map: 'Reference' }, { name: 'date', map: 'Date', type: 'date' }, { name: 'so_reference', map: 'SO_Reference' }, { name: 'description', map: 'Description' }, { name: 'total', map: 'Base_Total', type: 'float' }, { name: 'buyer_details', map: 'Buyer_Details' }, { name: 'buyer_reference', map: 'Buyer_Reference' }, { name: 'order_number', map: 'Order_Number' }, { name: 'order_date', map: 'Order_Date', type: 'date' } ], sort: function(){ // Update the grid and send a request to the server. $("#sh_grid").jqxGrid('updatebounddata', 'sort'); }, beforeprocessing: function(data){ if(data!=null){ // Update the total records source.totalrecords = data.rows; } } }; // Get the shipments var settings = { loadServerData: function(serverdata,source,callback){ MN.ajax({ url: source.url, dataType: source.datatype, data: serverdata, cache: false, success: function(data){ // Set the aggregates $('#sh_quantity_aggregate').text(data.rows); $('#sh_total_aggregate').html('£'+data.aggregates.total); $('#sh_average_aggregate').html('£'+data.aggregates.average); // Run the before processing callback source.beforeprocessing(data); dataAdapter.loadjson(null,data.results,source); callback({ records: dataAdapter.records, totalrecords: source.totalrecords }); }, error: function(msg){ MN.ajaxError(msg,function(msg){ // Place the error message into the grid localizationobj.emptydatastring = msg; callback({ records: [] }); }); } }); } }; // Initialize the data adapter var dataAdapter = new $.jqx.dataAdapter(source,settings); // Initialize the grid $("#sh_grid").jqxGrid({ width: 1196, altrows: true, source: dataAdapter, theme: 'metro', selectionmode: 'singlerow', sortable: true, pageable: true, autoheight: true, pagesize: 15, pagesizeoptions: [15,30,50,100], virtualmode: true, enabletooltips: true, columnsresize: true, columns: [ { text: 'Ref.', datafield: 'reference', width: '8%' }, { text: 'Date', datafield: 'date', align: 'center', cellsalign: 'center', cellsformat: 'dd-MMM-yyyy', width: '8%' }, { text: 'Name', datafield: 'buyer_details', width: '23%' }, { text: 'Ref.', datafield: 'buyer_reference', width: '10%' }, { text: 'Contract No.', datafield: 'so_reference', width: '8%' }, { text: 'Description', datafield: 'goods_description', width: '16%' }, { text: 'Value', datafield: 'total', align: 'right', cellsalign: 'right', cellsformat: 'c'+user_settings.dp_Value, width: '9%' }, { text: 'No.', datafield: 'bol_number', align: 'left', cellsalign: 'left', width: '10%' }, { text: 'Date', datafield: 'bol_date', align: 'center', cellsalign: 'center', cellsformat: 'dd-MMM-yyyy', width: '8%' } ], rendergridrows: function(obj){ return obj.data; } }); // Bind the bindingcomplete event $("#sh_grid").bind('bindingcomplete',function(){ // Set the currency symbol localizationobj.currencysymbol = "£"; // Apply the localization object $("#sh_grid").jqxGrid('localizestrings', localizationobj); });
Hi Benji6996,
The things which I find undefined in this code are:
1. datafields type is missing for some of your fields.
2. setting the localization is better to be in the Grid’s initialization by using the “localization” property. By doing this, you will avoid localizing your Grid on each data update which in your case will happen very frequently because you use server paging, sorting & filtering i.e if you set the localization property, you will improve your app’s performance.However, from this code I still can’t understand what would be the reason for the described behavior.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comIs the datafields ‘type’ a required parameter?
Unfortunately this is not the issue though. I think I have narrowed it down to a particular area having compared it to another one of my grids that is actually still working.
Could it be something to do with this:
source.beforeprocessing(data); dataAdapter.loadjson(null,data.results,source); callback({ records: dataAdapter.records, totalrecords: source.totalrecords });
Right, have confirmed that the issue is definitely occurring in the following line:
callback({ records: dataAdapter.records, totalrecords: source.totalrecords });
Shall I post up the data that is being passed?
There is only one difference between the dataAdapter.records when loading the initial page and when loading another page, this is the index of the items in it. For page one the object looks like this:
[Object, Object, Object, Object, Object...
However, for page 2, the object looks like this:
[15: Object, 16: Object, 17: Object, 18: Object...
The callback is obviously expecting the index of the dataAdapter.records to start at 0. Is this a bug, or should I correct it at my end?
Hi Benji6996,
We don’t have functions like loadjson or beforeprocessing. At least there is no documentation about these and they shouldn’t be used. we can’t help for using internal API.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comWhilst I appreciate this, it was you that encouraged me to use this function in the first place (see here: http://www.jqwidgets.com/community/topic/using-virtualmode-with-loadserverdata/). Regardless, the loadjson function is not what is causing the issue here… Essentially, I need to know what information and in what format it needs to be passed to
callback({ records: dataAdapter.records, totalrecords: source.totalrecords });
Could you possibly supply me with that info? Once I have this, I should be able to sort it 🙂
Hi Benji6996,
It’s in the format you are doing it right now.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comThen surely that means that there is a bug in the callback function?
The data that I am passing into the callback function has not changed since I upgraded to version 3.5.0…
Shall I post up the exact data object being returned by both page 1 and 2?
Hi Benji6996,
I don’t know where is the bug because the information is insufficient. If you would like, prepare and share a jsfiddle.net sample which demonstrates the reported behavior. If we confirm it, we would create a work item for future update.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comOkay, I will do my best to reproduce the issue and come back to you here when I have 🙂
Okay. I’ll be looking forward for that.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comIs it okay if I email you instead as the jsFiddle I have created contains links to our software and as it is currently under development, we do not wish to publish these?
And then once we have solved it, we can post up the solution here if you feel it may help others 🙂
-
AuthorPosts
You must be logged in to reply to this topic.