You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To this is easy enough to work around but SHould probably be changed.
data = [{id: 1, foo:'bar1'},{id: 2, foo:'bar2'}]
let row = grid.dataView.getItemById(1); //works
let row = grid.dataView.getItemById('1'); //doesn't work
In my system some table have string uuid's and some have just integers but i want to support both.
It seems that data view puts things in a map which ends up using 'has' to check for an id
* Gets a value indicating whether the given key is present in the map.
* @method has
* @param key The key of the item in the map.
* @return {Boolean}
*/
this.has=function(key){
returnkeyindata;
};
This is confusing since the in operator seems to PROPERLY accept strings or numbers for looking up keys.
My workaround is kind of hacky but seems to work.
let row = grid.dataView.getItemById(row_id);
if(!row) row = grid.dataView.getItemById(parseInt(row_id));
if(!row) console.error("Unable to find row in data view with that ID you sure its right? id:", row_id);
Does anyone have thoughts on why this might happen. or if there is a better fix. Thanks
The text was updated successfully, but these errors were encountered:
This is normal and no I don't consider it to be hacky and yes it's because it got switched to Map with PR #572 to optimize bulk operations.
Technically speaking it's the developer's responsibility to know and use the correct Type (it could be either a number or string and SlickGrid doesn't know which Type you're using in your dataset) and also since SlickGrid is a JavaScript lib (not a TypeScript lib) well there's no way to properly advise you to use the correct Type when querying the lib and most developers will only ever have 1 Type not 2 Types like your use case (which is very rare).
Considering the performance gain that we've got with PR #572, we will stick with Map, so again it's your responsibility to query the data in the correct Type, I don't see any problem with the lib.
Sounds good thanks, You are right that it is easy enough to detect the type and cast before the function call. And I cant see a use case where there are 2 different types in the id field. Worst case one could search the data the js way data.find(x=>x.id = row_id) but that probably doesn't help performance.
The real question is probably where is my code changing the int to a string or vise versa
To this is easy enough to work around but SHould probably be changed.
In my system some table have string uuid's and some have just integers but i want to support both.
It seems that data view puts things in a map which ends up using 'has' to check for an id
SlickGrid/slick.core.js
Lines 655 to 663 in 1db791d
This is confusing since the in operator seems to PROPERLY accept strings or numbers for looking up keys.
My workaround is kind of hacky but seems to work.
Does anyone have thoughts on why this might happen. or if there is a better fix. Thanks
The text was updated successfully, but these errors were encountered: