This does not work.
I don't have time to totally debug your code, but I think I have narrowed it down to the following: I think the bolded "fields" should be probably be changed to "fieldData"? My fix may or may not be correct or complete, but the code you have ends up resolving to fields["keyId"], which will never return anything since be definition the fields variable will only have the Fields structure { id: , text: }
ListView.prototype.findItemFromDS = function (dataSource, fields, parent) {
var _this = this;
var resultJSON;
if (dataSource && dataSource.length && fields) {
dataSource.some(function (data) {
var fieldData = getFieldValues(data, _this.listBaseOption.fields);
//(!(fid) || id === fid) && (!(ftext) || text === ftext) && (!!fid || !!ftext)
if ((fields[_this.fields.id] || fields[_this.fields.text]) &&
(!fields[_this.fields.id] || (!isNullOrUndefined(fieldData[_this.fields.id]) &&
fieldData[_this.fields.id].toString()) === fields[_this.fields.id].toString()) &&
(!fields[_this.fields.text] || fieldData[_this.fields.text] === fields[_this.fields.text])) {
resultJSON = (parent ? dataSource : data);
}
else if (typeof data !== 'object' && dataSource.indexOf(data) !== -1) {
resultJSON = (parent ? dataSource : data);
}
else if (!isNullOrUndefined(fields[_this.fields.id]) && isNullOrUndefined(fieldData[_this.fields.id])) {
var li = _this.element.querySelector('[data-uid="'
+ fields[_this.fields.id] + '"]');
if (li && li.innerText.trim() === fieldData[_this.fields.text]) {
resultJSON = data;
}
}
else if (fieldData.hasOwnProperty(_this.fields.child) && fieldData[_this.fields.child].length) {
resultJSON = _this.findItemFromDS(fieldData[_this.fields.child], fields, parent);
}
return !!resultJSON;
});
}
else {
resultJSON = dataSource;
}
return resultJSON;
};
Again, regardless of whether my fix is correct, the control is not working. I've spent hours trying to figure out why my code is incorrect. I may be wrong, but I do no longer believe the problem is on my end.
Thanks for looking into this. Please let me know if I have done something wrong or when this is corrected.