Search code examples
javascriptjquerykendo-uikendo-dropdown

kendo ui code is Not working fine in java script function why?


I have make a js function which is call on button click

in which there is 59 differnt values are assign to diffenrt Html element by java script.

Now i found all Values are assign properly

but there are 2 kendo ui drop down also on page, not dropdown is cascading so frist i assign value of 1st dropdown and accoding that dropdown 2nd dropdown refereshed and then i had to assign values but that 2nd drop down don't accept value.

why?

i had to put a alert in that function if i put alert then it's disply why?

code:--

if (c != null) {


    var Country = $("#CountryForPricing").data("kendoDropDownList");
                                alert(c);
                                Country.select(function (dataItem) 
                                  {
                                    return dataItem.Value == c;
                                });
                                CatalogPricingSetProgramExRate(c);
                            }

execution pointer is execute this function line by line this is prove by this alert function and " CatalogPricingSetProgramExRate(c) " is also called but dropdown don't get value.

if alert is removed then it's not work and if i put alert then it's work why? is there any timing issue?

can any one guide me..?

Regards, vinit


Solution

  • I can't be sure with the amount of code posted, but it sounds like your second dropdown is still populating with the button onclick function.

    I believe you need to wait for the cascade to finish before you can set it. You do a Timeout, but think you can handle it with the cascade event aswell.

    http://docs.telerik.com/kendo-ui/api/web/dropdownlist#events-cascade

    <input id="dropdownlist" />
    <script>
    $("#dropdownlist").kendoDropDownList({
      cascade: function() {
        // Handle the event
      }
    });
    </script>