Auto suggest lookup get value instead of name
Hi,
i have a auto suggest field with lookup (name/value) and want to use the "value" in a cascading autolookup. But I always get the name but not the value.

How can I get the value of the auto suggest field directly? Or how can I get it with java script?
-
Hi Andreas,
You can make use of below script for getting auto suggest control value.
Change your control names accordingly in the event itself.
// Default method to read control datasource
function GetSource(name) { var r = []; eFormHelper.getBoundData({fieldId: name}, function(d) { if (d.isSuccess) r = d.data; }); return r; }
// Dafault method for Get Set control values
function Set(name, value) { eFormHelper.setFieldValue({ fieldId: name, value: value }); }
function Get(name) { var r = ''; eFormHelper.getFieldValue({ fieldId: name }, function (d) { if (d.isSuccess) r = d.data; }); return r; }
// Method which compares selected name with databound
function GetAutoSuggestValue(ctrl) {
var value = ''; // Selected Value to store
var name = Get(ctrl); // Selected Name to compare
var dataSource = GetSource(ctrl);
$.each(dataSource, function(i, d) {
if(name == d.Name) value = d.Value;
});
return value;
}
// Event which auto read auto suggest control value
$(document).on('change', '#AutoSuggest1', function (e) {
Set('SelectedValue', GetAutoSuggestValue('AutoSuggest1'));
});More info: Basically the script compares with the selected text and returns the selected value.
請登入寫評論。
評論
2 條評論