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.
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.
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://ko.infragistics.com/support
Hi,I've submitted a bug with internal ID #112518 about this.Yes, the igDataSource iterates over the source data with a for cycle, seeing as how the data is usually a regular array.Associative arrays in JavaScript are a strange breed and using a for in loop just because of them isn't a proper solution, in my opinion.I've read several articles about the doubtful correctness and poor performance of the for in loop, by sticking to Murphy's law, I can't find those links right now :(However, I can argument myself with the following performance tests (and results):http://jsperf.com/native-underscore-and-jquery-loop-tests/4 http://jsperf.com/iterating-over-arrays-and-objects2 As you can see, the for in loop has the worst performance when compared to other loops.Nonetheless our development team may be able to provide a fix for your scenario.PS: A workaround I can offer would be to iterate through the input data and record it in a regular javascript array using the push() function and then set that array as the source data for the igGrid.Hope these details have helped you out.Cheers,Borislav