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

Binding combobox to a remote Rest Service.

1 Answer 251 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Satish
Top achievements
Rank 1
Satish asked on 16 Apr 2012, 08:21 PM
I want to bind the combo box to a remote rest service which takes a partial name as query string parameter. Following is the code I have.

$("#combobox").kendoComboBox({
                dataTextField: "Description",
                dataValueField: "Code",
                filter: "contains",
                minLength: 3,
                autoBind: false,
                dataSource: {
                    type: "json",
                    serverFiltering: true,
                    transport: {
                        read: {
                            url: serviceUrl + "HpCodes",
                            contentType: "application/json; charset=utf-8",
                            dataType: "json",
                            data: {
                                partialName:
                                    function () {
                                    return $("#combobox").val();
                                }
                            }
                        }
                    }
                }
            });

So I was hoping when uses types in 3 chars it would emit a call to the service as <serviceUrl>/HpCodes?partialName=tes
but it doesn't seem to be doing that instead it sends the following request 
GET <serviceUrl>/HpCodes?partialName=&filter%5Blogic%5D=and&filter%5Bfilters%5D%5B0%5D%5Bfield%5D=Description&filter%5Bfilters%5D%5B0%5D%5Boperator%5D=contains&filter%5Bfilters%5D%5B0%5D%5Bvalue%5D=tes HTTP/1.1
This looks like a oData query annd in my wcf service the partialName is empty string.

Another thing I noticed was that even though I set the minLength to 3 if I click the drop down button with out entering anything the the input area it still calls the service.

1 Answer, 1 is accepted

Sort by
0
Accepted
Georgi Krustev
Telerik team
answered on 18 Apr 2012, 11:40 AM
Hello Satish,

 
You need to modify the transport of the dataSource if you need to send some additional values like this:

transport: {
                        read: {
                            url: serviceUrl + "HpCodes",
                            contentType: "application/json; charset=utf-8",
                            dataType: "json",
                            data: function () {
                                return {
                                   partialName: $("#combobox").val()
                                }
                            }
                        }
                    }

Currently we do not prevent binding on the combobox if the input's length is less than the minLength. We will log your request and if other users wants the same functionality we will shedule it for investigation.

Kind regards,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
ComboBox
Asked by
Satish
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or