In your examples you have:
var products = [];
products[0] = { "ProductID": 1, "Name": "Adjustable Race", "ProductNumber": "AR-5381" };
products[1] = { "ProductID": 2, "Name": "Bearing Ball", "ProductNumber": "BA-8327" };
products[2] = { "ProductID": 3, "Name": "BB Ball Bearing", "ProductNumber": "BE-2349" };
products[3] = { "ProductID": 4, "Name": "Headset Ball Bearings", "ProductNumber": "BE-2908" };
this works fine, but what if I wanted it instead to be:
products[1] = { "ProductID": 1, "Name": "Adjustable Race", "ProductNumber": "AR-5381" };
products[2] = { "ProductID": 2, "Name": "Bearing Ball", "ProductNumber": "BA-8327" };
products[3] = { "ProductID": 3, "Name": "BB Ball Bearing", "ProductNumber": "BE-2349" };
products[4] = { "ProductID": 4, "Name": "Headset Ball Bearings", "ProductNumber": "BE-2908" };
where the key to the array is the associated productid, instead of just its index. Either way is equally valid in javascript, but when I try it this way instead of the first way, I get an exception saying:
Microsoft JScript runtime error: There was an error parsing the array data and applying the defined data schema: Unable to get value of the property 'ProductID': object is null or undefined
and if I look at it in the debugger it is because it is trying to get it for data[0] instead of data[1] . Seems like maybe datasource is doing (for i = 0; i < data.length; i++) when it should instead be doing (for row in rows) - could this be fixed???
The reason that I would want to do this is that I have several tables with alot of data in them, and I'd like to be able to navigate between them by primary key without having to iterate the whole table to find the item I'm interested in when I navigate.
Hello MolallaComm ,
I’ve created a private case regarding this: CAS-92250-RFVBYY and linked it with the development issue logged.
You can view the status of the development issue connected to this case by selecting the "Development Issues" tab when viewing this case on the web site.
Please let me know if you need more information.
Best Regards,
Maya Kirova
Developer Support Engineer
Infragistics, Inc.
http://es.infragistics.com/support
After looking at the performance characteristics Borislav mentioned, I think I will take a different approach - but hopefully this thread will still be around should anyone else run into the problem. In addition to the performance, there is also a fact that the associative approach relies on artifacts of object and when you do a the foreach you also get back the functions and prototypes off object in addition to just the items in your pseudo array.