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

Multiple dropdownlists sharing the same data items.

1 Answer 311 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Rene
Top achievements
Rank 1
Rene asked on 07 Mar 2014, 11:19 PM
I have a grid where when expanding a row I have a dropdownlist that loads it's items via ajax/json.

Now, when I expand multiple rows in 1 shot - the back end controller method used to load the items is called for each drop down (1 per detail expanded row) where the ddl's items are identical for each ddl.

Is there any way client side that we could have multiple dropdownlists refer to one set of items for selection?

Basically - something like:

a) call the controller method via ajax and get the items.
b) have each ddl point to that collection of items

Caching on the server is not an option.

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 11 Mar 2014, 02:43 PM
Hello Rene,

Using the same data for all dropdownlist is possible by using a shared dataSource and the JavaScript initialization e.g.
<script type="text/kendo" id="detail">
    <div>
        <input id="ddl#=MasterModelID#" />
    </div>
    <script>
        $("\#ddl#=MasterModelID#").kendoDropDownList({
            dataSource: sharedDataSource,
            dataTextField: "TextField",
            dataValueField: "ValueField"
        });
    <\/script>
</script>
<script type="text/javascript">
    var sharedDataSource = new kendo.data.DataSource({
        transport: {
            read: {
                url: "URL"
            }
        }
    });
    sharedDataSource.read();
</script>


Regards,
Daniel
Telerik

DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

Tags
DropDownList
Asked by
Rene
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or