This is a migrated thread and some comments may be shown as answers.

Autocomplete issue

0 Answers 153 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
Willem
Top achievements
Rank 1
Willem asked on 13 Jan 2012, 09:18 AM

I am using the kendo ui autocomplete on one of my pages. I am having so issues retrieving the value entered in the autocomplete input box. Below is a sample of the code I use to get autocomplete suggestions with a WebMethod via Ajax:

<P>$(".input_project").kendoAutoComplete({<BR>                   
minLength:
1,<BR>                   
dataTextField:
"value",<BR>                   
dataSource:
{<BR>                       
serverFiltering:
true,<BR>                       
serverPaging:
true,<BR>                       
schema:
{<BR>                           
data:
"d"<BR>                       
},<BR>                       
transport:
{<BR>                           
read:
{<BR>                               
url:
"<remote url>",<BR>                               
data: function ()
{<BR>                                   
return
{<BR>                                       
valuetocompare:
$(".input_project").val()<BR>                                   
};<BR>                               
},<BR>                               
contentType: 'application/json;
charset=utf-8',<BR>                               
type:
'POST',<BR>                               
dataType:
'json'<BR>                           
},<BR>                           
parameterMap: function (options)
{<BR>                               
return
kendo.stringify(options);<BR>                           
}</P>
<P>                       
}<BR>                   
},<BR>                   
change: function ()
{<BR>                       
var value =
this.value();                       
<BR>                       
$('#selectedProject').val(value);<BR>                   
}<BR>               
});<BR></P>

The problem in this case lies in the fact that I have multiple input fields with the same css class to identify my autocomplete fields. The idea is that all these input fields would be having an autocomplete on them. To get an idea of what I am building: I have a table with which contains both spans and div with dynamic id values. To simulate inline editing a toggle visibility on these div and spans.

Normally if you would like to retrieve data from the autocomplete, you would do something like below, but in my case this would not work since there are more input elements that carry the same css class. I know this is not the way to use autocomplete, since normally every input would have it's own identifier. Is there any way I can make this work. Right now I am using hidden fields to store the value entered but I think there should be a more efficient way to accomplish this behaviour.

<BR>data: function ()
{<BR>                                   
return
{<BR>                                       
valuetocompare:
$('#input_project').val()<BR>                                   
};<BR>                               
},

No answers yet. Maybe you can help?

Tags
AutoComplete
Asked by
Willem
Top achievements
Rank 1
Share this question
or