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

Combobox datasource server filtering

4 Answers 867 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
CH
Top achievements
Rank 1
CH asked on 15 Jul 2013, 08:11 AM
Hi,

I wish to create a combobox which when user enter 3 character
then the data source retrieve filtered data from server with the POST variable of keyword.

But i cant make the data source retrieve new data with combobox text, here is my code:

                var combo=$("#input_customer").kendoComboBox({
                dataTextField: "title",
                dataValueField:"entry_id",
                filter:"contains",
                minLength: 3
            }).data("kendoComboBox");
 
            var customer_ds=new kendo.data.DataSource({
                transport: {
                    read: {
                        type:"POST",
                        dataType: "json",
                        serverFiltering:true,
                        data:{keywords:combo.text()},
                        url: "ajax/customer"
                    }
                }
            });
 
            $("#input_customer").data("kendoComboBox").setDataSource(customer_ds);

4 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 15 Jul 2013, 01:12 PM
Hello Cheng-how,

I believe that the problem is caused by a syntax mistake - serverPaging should be peroperty of the DataSource object.

var combo=$("#input_customer").kendoComboBox({
    dataTextField: "title",
    dataValueField:"entry_id",
    filter:"contains",
    minLength: 3
}).data("kendoComboBox");
 
var customer_ds=new kendo.data.DataSource({
    serverFiltering:true,
    transport: {
        read: {
            type:"POST",
            dataType: "json",
            data:{keywords:combo.text()},
            url: "ajax/customer"
        }
    }
});
 
$("#input_customer").data("kendoComboBox").setDataSource(customer_ds);

I hope this will help.

Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
CH
Top achievements
Rank 1
answered on 15 Jul 2013, 01:52 PM
Thanks Alexander, i fixed that and it does run the query to server, however,
the text() method of kendoComboBox return empty string until user focus out the combo box. anyway to fix this problem?

0
CH
Top achievements
Rank 1
answered on 15 Jul 2013, 02:18 PM
Hi Alexander, I found the problem is the data object of datasource doesn't change when new request to server.
How to refresh the read object?

i tried to use .read() method of datasource, but i can't find any key down event for combobox,
it dispatch a change event only when user focus out.
0
Alexander Valchev
Telerik team
answered on 17 Jul 2013, 07:47 AM
Hello Cheng-how,

Please use the parameterMap function of the DataSource to modify the additional data that is being sent with the read request. The function is evaluated every time when new jQuery.ajax request is started.

Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Data Source
Asked by
CH
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
CH
Top achievements
Rank 1
Share this question
or