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.

Viewing 15 posts - 1 through 15 (of 21 total)
  • Author
  • Cannot read property 'uid' of undefined #62176

    Benji6996
    Participant

    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

    Cannot read property 'uid' of undefined #62177

    Peter Stoev
    Keymaster

    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 Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Cannot read property 'uid' of undefined #62179

    Benji6996
    Participant

    Its 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);
    });
    Cannot read property 'uid' of undefined #62182

    Peter Stoev
    Keymaster

    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 Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Cannot read property 'uid' of undefined #62183

    Benji6996
    Participant

    Is 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 });
    Cannot read property 'uid' of undefined #62184

    Benji6996
    Participant

    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?

    Cannot read property 'uid' of undefined #62187

    Benji6996
    Participant

    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?

    Cannot read property 'uid' of undefined #62189

    Peter Stoev
    Keymaster

    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 Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Cannot read property 'uid' of undefined #62191

    Benji6996
    Participant

    Whilst 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 🙂

    Cannot read property 'uid' of undefined #62192

    Peter Stoev
    Keymaster

    Hi Benji6996,

    It’s in the format you are doing it right now.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Cannot read property 'uid' of undefined #62197

    Benji6996
    Participant

    Then 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?

    Cannot read property 'uid' of undefined #62200

    Peter Stoev
    Keymaster

    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 Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Cannot read property 'uid' of undefined #62207

    Benji6996
    Participant

    Okay, I will do my best to reproduce the issue and come back to you here when I have 🙂

    Cannot read property 'uid' of undefined #62209

    Peter Stoev
    Keymaster

    Okay. I’ll be looking forward for that.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Cannot read property 'uid' of undefined #62216

    Benji6996
    Participant

    Is 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 🙂

Viewing 15 posts - 1 through 15 (of 21 total)

You must be logged in to reply to this topic.