Adding a dropdown list to a table causing datasource to call webservice multiple times

2 posts, 0 answers
  1. Shane P
    Shane P avatar
    86 posts
    Member since:
    Sep 2012

    Posted 16 May 2012 Link to this post

    I am using mvc to generate my table then I am apply the kendo grid to the table.

    In one of the grid cells I am using a kendo dropdownlist. I am having a couple of problems. My script look likes

    $(document).ready(function () {
               var dataSource = new kendo.data.DataSource({
                   transport: {
                       read: {
                           url: "/API/store/get",
                           dataType: "json",
                           data: function () {
                               return {
                                   businessId: $("#BusinessId").val()
                               };
                           }
                       }
                   }
               });
               $("#outlets").kendoGrid({ sortable: true });
               $(".dropdown").kendoDropDownList({
                   dataTextField: "StoreName",
                   dataValueField: "StoreId",
                   optionLabel: "Select...",
                   dataSource: dataSource
               });


    Problem 1. The datasource is calling my webservice for every dropdown list bound to it. Is it possible to only have the service called once?

    Problem 2. the optionLabel value is only applied to 1st dropdownlist and no others. Is this a bug or something wrong with the way I have configured it?

    Thank you!
  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3747 posts

    Posted 22 May 2012 Link to this post

    Hello Shane,

     
    Straight upto your questions:

    #1:
    I was not able to reproduce the described problem. Check this screencast. The datasource can make more than one request if the read/fetch method is called numerious times before the data is loaded. If you need to ensure only one request I will suggest you bind the DropDownList widgets in the change event of the shared dataSource.

    #2:
    As it is shown in the screencast I was not able observe the depicted issue.

    Kind regards,
    Georgi Krustev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top