I recently got out of using dummy data for my slickgrid and now I'm using mongodb data that has an Id as an ObjectId
Before
{"_id":"123456789", "name": "Name"}
and I could set dataview using this
dataView.setItems(data, "_id");
Now Mongo gives me this from my db
{"_id":ObjectId("570e6d3cd9e2ce225877b8a8"), "name": "Name"}
And My java service posting the json, serializes it to this
{ "_id" : { "$oid" : "570e6d3cd9e2ce225877b8a8"} , "name": "Name"}
and the problem is that setItems sees all the _id's as an object and not as a unique id
I've tried things like
dataView.setItems(data, "_id.$oid");
and
dataView.setItems(data, "$oid");
But I can't get any of them to work. How should I be declaring setItems now to get the $oid?
Edit: Alright a friend thinks that dataView.setItems doesn't support deep mapping. I'm now looking into setting $oid to the top level but if anyone knows of another way, please help me out
So I couldnt get setItems to take $oid so I just changed the value of _id
$.each(data, function(index, value) {
value._id = value._id.$oid;
});
dataView.setItems(data, "_id");