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

ComboBox value=text when text item starts with an integer

2 Answers 89 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Travis
Top achievements
Rank 1
Travis asked on 16 Oct 2012, 03:21 PM
I'm using the code below for my combobox:

$("#ResourcesList").kendoComboBox({
            index: 0,
            placeholder: "Search by title/description",
            dataTextField: "Title",
            dataValueField: "ResourceID",
            filter: "contains",
            template: '<div style="padding: 10px;"><strong>#= Title #</strong>' + 
                '<div style="margin-top: 5px;" class="t1">#= Description #</div></div>',
            dataSource: {
                type: "jsonp",
                serverFiltering: true,
                serverPaging: true,
                pageSize: 20,
                transport: {
                    read: {
                        url: function (kcb) {
                            var strurl="/mysite/GetResourcesList?filtertext=" + 
                                $("#ResourcesList").data().kendoComboBox.text();
                            return strurl;
                        }
                    }
                }
            }
        });

Calling the following code will return the value of the combox except when an item's "Title" starts with an integer such as "2012 resource item title...".  In this case executing the code below returns the "Title" property instead of the "ResourceID" property.

alert($("#ResourcesList").data("kendoComboBox").value())

2 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 17 Oct 2012, 08:49 AM
Hello Travis,

 
The ComboBox widget allows custom values. When a custom value is entered the text and the value of the combobox is the same. I suppose this happens on your end. If this is not the case I will need a test project, which replicates the problem in order to review it locally. You can also test this online demo - enter "2012".

All the best,
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!
0
Travis
Top achievements
Rank 1
answered on 17 Oct 2012, 04:26 PM
I guess its good to create a test project to verify the problem :)  This problem was not what I thought.  If the item contains a line break character at the end of its text field, e.g. "2012 my title\n", then it exhibits the behavior described.  In my situation the title field data should not have a line break.  This was a result of imported data and I've fixed it for my project.
Tags
ComboBox
Asked by
Travis
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Travis
Top achievements
Rank 1
Share this question
or