Auto suggest lookup get value instead of name

Comments

2 comments

  • Avatar
    Sampat Patil

    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.

    1
    Comment actions Permalink
  • Avatar
    Andreas Blersch

    THX, it's working

    1
    Comment actions Permalink

Please sign in to leave a comment.