Multiple dropdownlists sharing the same data items.

2 posts, 0 answers
  1. Rene
    Rene avatar
    65 posts
    Member since:
    Nov 2010

    Posted 07 Mar 2014 Link to this post

    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.
  2. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 11 Mar 2014 Link to this post

    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.

  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top