1

I am using kendo grid in my application. In that grid, I have used kendo drop down list. I have an array for datasource of that dropdownlist. The array looks like

var arr = [{text: "demo 1", value: 1}, {text: "demo 2", value: 2}]

My Dropdownlist Looks like:

    $("#grid").kendoGrid({
        dataSource: dataSource,
        navigatable: true,
        pageable: true,
        height: 550,
        filterable: {
            mode: "row"
        },
        sortable: {
            mode: "single",
            allowUnsort: false
        },
        toolbar: ["create"],
        columns: [
            { field: "Item", title: "Item", width: "300px", editor: categoryDropDownEditor }
        ],
        editable: true
    });

    function categoryDropDownEditor(container, options) {
        $('<input data-text-field="text" data-value-field="value" data-bind="value:' + options.field + '" />')
            .appendTo(container)
            .kendoDropDownList({
                dataSource: arr,
                autoBind: true,
                dataTextField: "text",
                dataValueField: "value",
            });
    }

It is showing the text in dropdown correctly but after selecting the option from drop down it shows object object as a selected text.

Attached the screenshot of the drop down selected value and after option after selecting Image of option selecting and After option selected

I have tried a lot of solutions but didn't work. It will be great if someone provides the solution.

Thanks

2 Answers 2

1

I Just Have Updated "Cara Tilos's" Jsfiddle code,

http://jsfiddle.net/0zauzskn/5/

This will give you your desired result.

I have added

schema: {
    model: {
        fields: {
            item: { type: "string" }
        }
    }
}

Into your dataSource

Best Of Luck.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the response but that is not working because I have change dataValueField from text to value as I want to get the selected option's value to process it further. In your fiddle it is returning text instead of value as dataValueField is mentioned as text.
0

Try removing the data-text-field and data-value-field on your categoryDropDownEditor.

Made a jsFiddle for you. Check this one.

3 Comments

The fiddle provided by you also has same issue. Try adding new record and then select the option from drop down. It is showing "object object"
I added a valuePrimitive on kendoDropDownList. jsfiddle.net/0zauzskn/6
Thanks but adding valuePrimitive shows me the value of that option if I use dataValueField: "value" instead of "text". I have to add dataValueField as value because I need to save it in DB.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.