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

autocomplete against text field but post numerical id with input field

0 Answers 21 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
Martijn
Top achievements
Rank 1
Martijn asked on 16 Jul 2012, 12:05 PM
I've implemented the autocomplete component successfully to search against a list of website urls. However when I submit my form i want to submit the numerical id value of the site not the text value. Is this possible?

$("#maintSiteId").kendoAutoComplete({
                minLength: 3,
                dataTextField: "site_url",
                dataValueField: "site_id", // this doesn't seem to work and is depreciated?
                filter: "contains",
                height: 320,
                dataSource: {
                    pageSize: 20,
                    transport: {
                        read: {
                            url: "/Sites/DataJsonSites.cshtml",
                            dataType: "json",
                            type: "GET"
                        },
                        parameterMap: function(options) {
                            return $.extend(options, {
                                id: '',
                                title: $("#maintSiteId").data("kendoAutoComplete").value()
                            });
                        }
                },
                placeholder: "Select site...",
                separator: ", ",
                suggest: true
                }
            });

Input field contained within standard <form>
<input class="span6" id="maintSiteId" name="maintSiteId" style="width: 320px; margin-left: 0;"/>

Sample JSON data being used;
[{"site_id":1,"site_url":"www.mysite1.com","site_name":"my site 1"},{"site_id":2,"site_url":"www.mysite2.com","site_name":"my site 2"}] 

No answers yet. Maybe you can help?

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