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

no toLowerCase method problem

7 Answers 290 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
david
Top achievements
Rank 1
david asked on 10 Feb 2014, 02:12 PM
I've been beating this dead horse for the last 2 weeks, on and off and still can't figure it out.

This is my datasource js:

var myDS = new kendo.data.DataSource({
    transport: {
        read: {
            url: 'dataset.json'
            ,dataType: "jsonp"
            ,data: { select: "ID,NAME" }
        }
    },
    schema: {
        data: function(response) {
            return response.features;
        },
        model: {
            fields: {
                "properties.ID": { type: "number" },
                "properties.NAME": { type: "string" }
            },
        }
    }
});

This is my dropdownlist init:

$("#dropdown").kendoComboBox({
    placeholder: "...",
    autoBind: false,
    suggest: true,
    dataTextField: "properties.NAME",
    dataValueField: "properties.ID",
    dataSource: myDS
});

This is my datasource table:

ID  |  NAME
-------------
1   |   0,4
2   |   6
3   |   10
4   |   20
5   |   35
6   |   110
7   |   220
8   |   400

The error 'Object doesn't support property or method 'toLowerCase'' pops up when trying to init the ddl - because my textfield values are basically numbers (but set as string in model and database!!), which are treated as strings - if I check the return values of datasource in Firefox and Chrome i see that my return values are treated as strings. The same goes for IE10 and above, but IE9 and IE8 treat those values as numbers, even if I've set the name field as string in datasource.

I've tried everything, I even went through all of the return rows of dataset and converted all of the name values to string, but that didn't help either. Not only that - if i try to print the response.features to console i get undefined in ie8/ie9 (what?).

Can anyone help me?

7 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 10 Feb 2014, 03:09 PM
Hello David,

Can you show us how the server-side response looks like? Just paste here the JSON response.

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
david
Top achievements
Rank 1
answered on 10 Feb 2014, 05:06 PM
Ok, I was maybe a bit too quick by saying I get string from the DB, but still, I have the name field as string in ds model:

{
    "features" :
    [
        {
            "type":"Feature",
            "id": { "ID":1},
            "properties": {"ID":1, "NAME":  0.40000000000000002}
        },
        {
            "type":"Feature",
            "id": { "ID":2},
            "properties": {"ID":2, "NAME": 6}
        },
        {
            "type":"Feature",
            "id": { "ID":3},
            "properties": {"ID":3, "NAME": 10}
        },
        {
            "type":"Feature",
            "id": { "ID":4},
            "properties": {"ID":4, "NAME": 20}
        }
    ]
};


Doesn't datatype change according to the type specified in model?
0
Atanas Korchev
Telerik team
answered on 11 Feb 2014, 08:01 AM
Hi David,

I created a sample which should work as expected: http://jsbin.com/viwec/1/edit

The important part is the model configuration: 

model: {
        fields: {
          ID: { from: "properties.ID", type: "number" },
          NAME: { from: "properties.NAME", type: "string" }
        }
      }

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
david
Top achievements
Rank 1
answered on 11 Feb 2014, 10:44 AM
Hm, doesn't work on my side. By using from option in model fields, my ID and NAME fields get null and undefined values, and my dropdown options have undefined for text.

That's in firefox. In IE8 I still get toLowerCase error:

http://postimg.org/image/lb9qq2xiz/

e variable normally had 0.4, 6, 10, etc. values (name field), now it has object init, it's not even a string/integer anymore.
0
Atanas Korchev
Telerik team
answered on 11 Feb 2014, 12:03 PM
Hello,

The example works as expected at my side. I have attached a screenshot from firefox and IE.

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
david
Top achievements
Rank 1
answered on 11 Feb 2014, 12:06 PM
Yep, the jsbin example works, but fails at my app.

Strange.

Do you maybe have any idea why i get undefined response in IE8, but not other browsers?

...
 
data: function(response) {
     console.log(response); // <--- returns undefined in ie, but obj in other browsers
    return response.features;
},
 
...


If I could modify response features that would help too, but I can't in ie8, because of undefined return.

0
Atanas Korchev
Telerik team
answered on 11 Feb 2014, 12:11 PM
Hi David,

Unfortunately we are not sure what may cause undefined response only in IE8. Sometimes a trailing comma could break it. You could check if there isn't any trailing comma in your JavaScript code.

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