Posted 31 January 2018, 12:17 am EST
I am using this snippet to find an item using a key to change one of the fields:
function searchGridandUpdate(idkey, qty) {
var fg = document.getElementById('flexGrid');
var wfg = wijmo.Control.getControl(fg).itemsSource.items;
var item;
var pos;
for (var i = 0; i < wfg.length; i++) {
if (wfg[i].OrderItemKey === idkey) {
item = wfg[i];
pos = i;
break;
}
}
wfg[pos].QtyRemaining = wfg[pos].QtyRemaining - qty;
wijmo.Control.getControl(fg).collectionView.refresh(wfg[pos]);
if (wfg[pos].QtyRemaining <= 0) {
wijmo.Control.getControl(fg).collectionView.remove(wfg[pos]);
}
};
Seldomly I am getting a pos not defined error. I am expecting that it should always find the key that I am looking for. Is there any way to harden this? Is there a better way to look up a value in the data grid? Your thoughts are appreciated.
Matt