rrfive
rrfive

Reputation: 165

Populating a Kendo UI DropDownList in an Edit Form

I'm using Kendo UI's DropDownList widget within an edit form and can't seem to set the initial value according to the organisation's ID. I suspect it has everything to do with the 'index' but am stumped as to how to retrieve this information when the edit form fields are populated by a query and the dropdown's options are pulled from remote datasource.

$("#organisations").kendoDropDownList({
            dataTextField: "orgName",
            dataValueField: "organisationID",
            index: 0,
            optionLabel: "-- Select --",
            dataSource: {
                transport: {
                    read: "assets/data/data.clients.php"
                },
            }
        });

Any help is appreciated.

@rrfive

Upvotes: 0

Views: 1995

Answers (1)

Petur Subev
Petur Subev

Reputation: 20203

To initially select the item according to the field that you want to edit, you should use the value configuration. Here is an example:

e.g.

$(document).ready(function() {
              var theId = 3;

                $("#products").kendoDropDownList({
                    dataTextField: "ProductName",
                    dataValueField: "ProductID",
                    value:theId,
                    dataSource: {
                        transport: {
                            read: {
                                dataType: "jsonp",
                                url: "http://demos.kendoui.com/service/Products",
                            }
                        }
                    }
                });
            });

Upvotes: 2

Related Questions