Showing first item in DropDownList

4 posts, 0 answers
  1. Alex
    Alex avatar
    21 posts
    Member since:
    May 2013

    Posted 10 Jun 2015 Link to this post

    Hi

    I cascade three DropDownLists 'manually'. I don't use the built in cascadeFrom mechanism but I read the dataSource of the child DropDown within the change event of its parent. I do this because I attach a more complicated filter.

    This works fine so far, the dataSource is read, data is returned correctly and can be selected in the child DropDown - BUT - I would like the first item of the data to be selected immediately after reading the DataSource. Unfortunately, the child DropDown initially only shows an empty item after loading the new data although, there isn't an empty item defined.

    How can I force the child DropDown to show the first item after reading the remote data?

     

    Regards

     

    Alex

  2. Alex
    Alex avatar
    21 posts
    Member since:
    May 2013

    Posted 11 Jun 2015 in reply to Alex Link to this post

    Finally I found a hack to get the expected behaviour, but I don't like hacks too much:

    I really wonder why (before applying the hack) the first item of the child dropdown gets selected the first time I select an item of the parent but not the subsequent times.

    //  trigger read of child dropdownlist datasource
    .....
    change: function (e) {
                    species.dataSource.read();
                }
    .....
     
    // in child dropdownlist datasource force the first item to be selected
     
       requestEnd: function (e) {
                setTimeout(function () {
                           species.select(0);
                 }, 200);
         },

  3. Kendo UI is VS 2017 Ready
  4. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2877 posts

    Posted 12 Jun 2015 Link to this post

    Hi Alex,

    If there is no option label or empty item the DropDownList should select first item. You may observe the behavior in this demo page. How your DropDownList configuration differs from the one presented in the demo?

    Looking forward to your reply.

    Regards,
    Alexander Valchev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  5. Alex
    Alex avatar
    21 posts
    Member since:
    May 2013

    Posted 12 Jun 2015 in reply to Alexander Valchev Link to this post

    Hi

    thanks for your reply.
    I prepared an example showing the issue:

    http://www.improbabilitydrive.ch/swissbryophytes/app/src/view/taxon/dropdown.php

    1) The data loads correctly into the first dropdown and its first item is shown as expected.
    2) Now select an item from the first dropdown -> data is loaded correctly into the second dropdown and its first item is shown as expected.
    3) Now select another item from the first dropdown -> again data is loaded correctly into the second dropdown but it doesn't automatically show the first item although I don't load an empty item.

    Regards

     

    Alex

Back to Top
Kendo UI is VS 2017 Ready