This topic contains 4 replies, has 4 voices, and was last updated by  Hristo 6 years, 10 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • jqxInput autocomplete multiselect #81454

    Nidhi
    Participant

    Hi,

    I am trying to use jqxInput autocomplete multiselect feature. My data list has id and name. I have written the following code snippet:

    $scope.contactlistData= [{‘id’:1, ‘name’:’Nidhi’},
    {‘id’:2, ‘name’:’Raj’}]
    $scope.contactSourceObj={
    datatype: “json”,
    datafields: [
    { name: ‘id’, type: ‘integer’ },
    { name: ‘name’, type: ‘string’ },
    ],
    localdata:$scope.contactlistData
    };

    $(“#Contact”).jqxInput({
    height: 25, width: 250,
    source: function (query, response) {
    var item = query.split(/,\s*/).pop();
    $(“#Contact”).jqxInput({query: item});
    response($scope.contactObj);
    },
    renderer: function (itemValue, inputValue) {
    var terms = inputValue.split(/,\s*/);
    terms.pop();
    terms.push(itemValue);
    terms.push(“”);
    var value = terms.join(“, “);
    return value;
    }, displayMember: ‘name’,
    valueMember: ‘id’
    });

    html code:
    <input type=”text” id=”Contact” class=”form-control” ng-model=”contactval”
    ng-minlength=”3″ ng-maxlength=”255″/>

    This is working fine on the UI but I am unable to fetch the values selected by user in the input box.
    I have tried using :
    $(‘#Contact’).val()
    and $scope.contactval

    I get value of only the last element selected in the input and not all the value selected.
    Kindly suggest.

    jqxInput autocomplete multiselect #81463

    ivailo
    Participant

    Hi Nidhi,

    jqxInput have own val method.
    To get values with it you can use code similar to:
    var values = $("#input").jqxInput("val");
    It will return the correct values.

    Here is a demo.

    Best Regards,
    Ivailo Ivanov

    jQWidgets Team
    http://www.jqwidgets.com

    jqxInput autocomplete multiselect #81517

    Nidhi
    Participant

    Hi,
    Thanks for the reply. Although the jsfiddle works, but on my code only last object in the input box is coming in the value, not sure what I am missing

    Also, I tried using other solution provided in following link:
    http://www.jqwidgets.com/community/topic/getting-value-of-multiple-value-jqxinput/
    $('#inputDiv').jqxInput()[0].value
    This gives me all the names selected and not the entire object of the selected items.

    For now as a work around On select I am pushing each item selected to an array. This works as far as getting values are concerned, but it will not work correctly if after selecting a value in autocomplete the value is altered or removed. Do let me know if u can suggest some better solution.

    jqxInput autocomplete multiselect #99578

    natg504
    Participant

    I’m having the same issue as Nidhi. The demo does work, but my code still returns only the last item as an object. Was a solution ever found to this?

    jqxInput autocomplete multiselect #99609

    Hristo
    Participant

    Hello natg504,

    There has a solution provided by my colleague on this topic:
    https://www.jqwidgets.com/community/topic/jqxinput-autocomplete-multiselect/#post-81463
    His solution is this.
    Could you clarify it? Please, provide us a simple example of your case in https://www.jseditor.io/ or https://fiddle.jshell.net/

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.