Fórum

Can we fetch key instead of value in Liferay AutoComplete

thumbnail
Sai Sriharsha Kasturi, modificado 7 Anos atrás.

Can we fetch key instead of value in Liferay AutoComplete

Junior Member Postagens: 34 Data de Entrada: 21/10/12 Postagens Recentes
I have a scenario where User types the list of users available in an auto complete field. I'll fetch the userId and userName in the JSON and pass it as a source to AutoComplete.

My JSON is,

[
    {
        "userId": 3,
        "userName": "Test 1"
    },
    {
        "userId": 1,
        "userName": "Test 2"
    },
    {
        "userId": 2,
        "userName": "Test 3"
    }
]


My AutoComplete script is,

new A.AutoCompleteList({
		inputNode: '#<portlet:namespace />users',
		allowBrowserAutocomplete: 'false',
        activateFirstItem: 'true',        
        resultTextLocator: 'userName',
        resultHighlighter: 'phraseMatch',
        resultFilters: ['phraseMatch'], 
        minQueryLength: 2, 
        maxResults: 10, 
        queryDelimiter: ',', 
        render: 'true',
        source: users
   });


When user types he/she gets the user names in the auto-complete separated by comma. So when I submit the form I get the user names in the controller. Is there any option where I get userIds instead of userNames into the controller?