Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 94857

DataValueField does exist ?

$
0
0

READ THIS SOLUTION

None of the above suggested solutions is helpful at all honestly.  Even looping through the dataSource looking for a match can be bad, because its possible you have two different records with same 'name'.  

And dropDownList is just NOT desired, nor is multiSelect!

Quite honestly, the lack of dataValueField is inexcusable.  Breaks pattern of other widgets and for NO good reason.  Telerik should fix this, not argue that you should use a different widget.

 

BULLETPROOF SOLUTION FOR NOW

This is just an example that assumes some things about your datasource, but holds true no matter what datasource you use.

01.$("#contactSearch").kendoAutoComplete({
02.dataSource: {
03.type: "odata",
04.transport: {
05.read: "your data source url here"
06.},
07.serverSorting: true,
08.serverFiltering: true
09.},
10.filter: "contains",
11.dataTextField: 'name',
12.dataValueField: 'id'// <-- this doesn't work, but should!
13.template: '<span data-recordid="#= id #"> #= name #</span>', // here we just use a template and put the id as data on the span wrapping the name
14.select: function(e) {
15. 
16.// this is how you grab the id from the item selected
17.console.log(e.item.find('span').data('recordid'));
18.}
19.});

 Never used the code formatter of this forum, hopefully it adds indents.

 

ENJOY!

 


Viewing all articles
Browse latest Browse all 94857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>