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

Selecting initial value combo box

0 Answers 220 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 10 Oct 2012, 04:28 PM

Hello,

I'm trying to tweak my combo box for optimum performance but what I'm trying to do is either not possible or I do not know how to do it properly.

What I want to happen is this :

1. When my page loads I want it to load only the selected item. I'm setting my dataSource to autoBind false and creating an input with a single option which is the selectedValue that I return back from the server. Then on the open I'm selecting that initial selected value out of the returned results. The idea behind this is I want to display selectedValue but do not want load rest of results unless user accesses the dropdown.

2. When typing in the comboBox I want each request to be sent back to the server.  Currently it seems the way I have it setup that initially grabs the data from the server but then it does not callback to server as I change my typed value but instead limits value based on values already returned. The purpose behind this is my comboBox may return hundreds, if not thousands of records and I do not want it loading the whole set.

$('body').ready(function () {
 
 
                var jqWidget = $("#myWidget");
                var selectedValue = 1;
 
                var remoteDataSource = { transport:
                {
                    read:
                    {
                        dataType : "jsonp",
                        url : "http://localhost:8080/detail/000/q",
                        data :
                        {
                            retrieveValues : "true",
                            widgetName : "manufacturingLocation"
                        },
                        autoBind : false,
                        autoSync : true
                    },
                    serverFiltering: true
 
                }
                };
 
                var selectDropdownFunction = function( e )
                {
                    selectInitialValue( jqWidget, selectedValue );
                };
 
                jqWidget.kendoComboBox( {
                                                      dataSource : remoteDataSource,
                                                      autoBind : false,
                                                      dataTextField: "value",
                                                      dataValueField: "id",
                                                      open: selectDropdownFunction,
                                                      filter: "contains",
                                                      suggest: true,
                                                      index: 0,
                                                      delay: 800
 
                                                  } );
 
 
            });
 
            function selectInitialValue( jqWidget, selectedValue )
            {
                jqWidget.data('kendoComboBox').value(selectedValue);
            }


Any ideas how to do this? Or am I doing something wrong?

No answers yet. Maybe you can help?

Tags
ComboBox
Asked by
Eric
Top achievements
Rank 1
Share this question
or