PDA

View Full Version : Ext JS 4.2 - Different variables in a store with different counts



kayasa
26 May 2015, 12:40 PM
From Ext JS 4.2 code, I am calling a service which returns the below json



"data":{"variables":{"out_source_index_mv":["1","16","8","17","13","17","24","19","11","19","12","22","23","5","15","4","25","10","20","0","14","18","21","7","6","26","3","9"],

"out_type_mv":["approve","approve","approve","approve","approve","approve","approve","approve","approve","approve","approve","approve","approve","approve","approve","approve","approve","approve","approve","approve","approve","approve","approve","approve","approve","approve","approve","approve"],

"out_target_mv":["Move Bill To Tracking No Folder-1","Update Comments of Requestor","Set Permissions on Form for Requestor Rejected by FA","Update Comments of FA Rejection","WF Completed Permissions on Form","Update Comments of FA","Set Permissions on Form for Requestor Rejected by RM","Update Comments of RM Rejection","Set Permissions on Bill","Update Comments of RM","Reporting Manager Approves","End","Finance Approves","Send Notification to Requestor","Set Permissions on Bill after WF Complete","Move Bill To Tracking No Folder-2","Send to Requestor","Set Permissions on Bill for Requestor Rejected by RM","Set Permissions on form for Reporting Manager","Set Permissions on Attachments","Set Permissions-Tracking No. Folder","Move Bill To Tracking No Folder","Set Permissions on form for Reporting Manager","Send to Requestor","Set Permissions on Bill for Requestor","Set Permissions on Bill for RM","Set Permissions on form for Finance","WF Completed Permissions on Attachments"],

"out_status_mv":["completed","completed","completed","completed","completed","completed","completed","completed","completed","completed","completed","completed","completed","completed","completed","completed","completed","completed","completed","completed","completed","completed","completed","completed","completed","completed","completed","completed"],

"out_nodes_mv":["Set Permissions-Tracking No. Folder","Update Comments of Requestor","End","Move Bill To Tracking No Folder","Set Permissions on Bill for Requestor Rejected by RM","Set Permissions on form for Finance","Set Permissions on Form for Requestor Rejected by FA","Set Permissions on Bill for Requestor","Update Comments of FA Rejection","WF Completed Permissions on Form","Set Permissions on Form for Requestor Rejected by RM","Update Comments of RM","Set Permissions on Bill for RM","Update Comments of FA","Initiate","WF Completed Permissions on Attachments","Send to Requestor","Finance Approves","Set Permissions on Bill","Reporting Manager Approves","Set Permissions on Attachments","Move Bill To Tracking No Folder-1","Set Permissions on Bill after WF Complete","Send Notification to Requestor","Update Comments of RM Rejection","Move Bill To Tracking No Folder-2","Set Permissions on form for Reporting Manager"],

"out_target_index_mv":["21","1","6","8","9","13","10","24","18","11","19","2","17","23","22","25","16","4","26","20","0","3","26","16","7","12","5","15"],

"out_source_mv":["Update Comments of Requestor","Send to Requestor","Update Comments of FA Rejection","Finance Approves","Update Comments of FA","Finance Approves","Update Comments of RM Rejection","Reporting Manager Approves","Update Comments of RM","Reporting Manager Approves","Set Permissions on Bill for RM","Set Permissions on Bill after WF Complete","Send Notification to Requestor","Set Permissions on form for Finance","WF Completed Permissions on Attachments","Set Permissions on Bill for Requestor Rejected by RM","Move Bill To Tracking No Folder-2","Set Permissions on Form for Requestor Rejected by RM","Set Permissions on Attachments","Set Permissions-Tracking No. Folder","Initiate","Set Permissions on Bill","Move Bill To Tracking No Folder-1","Set Permissions on Bill for Requestor","Set Permissions on Form for Requestor Rejected by FA","Set Permissions on form for Reporting Manager","Move Bill To Tracking No Folder","WF Completed Permissions on Form"]}},

All the keys (like 'out_source_index_mv', 'out_target_index_mv' etc.) have 28 values with the exception of 'out_nodes_mv' which has 27 values.

This is causing problems when I iterate over the store. So, in the Ext Js code, I have



var count = store1.getCount(); for (var i = 0; i < count; i++) {
var rec = store1.getAt(i); console.log('source : '+rec.get('out_source_mv')+' target : '+rec.get('out_target_mv')+' sourceIndex : '+rec.get('out_source_index_mv')+' targetIndex : '+rec.get('out_target_index_mv'));
console.log(' nodes : '+rec.get('out_nodes_mv'));
}


This loop works fine for the first 27 records. As soon as it reaches the 28th record, below line throws an error in the console



console.log(' nodes : '+rec.get('out_nodes_mv'));

Error is (thrown by D3 which is getting called from within Ext JS) -


Uncaught TypeError: Cannot read property 'neighbours' of undefined

Since this json is being returned by an external service there is no way for me to ensure that count of values in 'out_nodes_mv' would match the count of values in other keys (all other keys would always have the same number of values).

How can I prevent this error?

Thank you.

f.baron
27 May 2015, 10:45 PM
Hi!
Can you provide the store definition?