Saeed ur Rehman
Saeed ur Rehman

Reputation: 737

bind kendo dropdown from ajax post result

I have been searching it for many hours but did not get any solution yet.

here is the kendo dropdown

 <div id="formMain" class="at-form>
  <span data-name="ERP_DimensionCodesList" id="ERP_DimensionCodesList" data-type="picklist"></span>
</div>

here is ajax call

  window.Page.Data.getDimensionCodeList = function (dimension, company) {
            window.Page.get(
                "/api/ERPIntegrationDimensionSetup/GetDimensionCodeList"
                , { dimension: dimension, company: company }
                , window.Page.Data.dataReceivedDimension
            );
        }
        window.Page.Data.dataReceivedDimension = function (data) {
            debugger;
 var dataSource = [];
            for (i = 0; i < data.length; i++) {
                dataSource.push({ text: data[i].ListID, value: data[i].ListName })
            };
            $("#ERP_DimensionCodesList").kendoDropDownList({
                dataTextField: "text",
                dataValueField: "value",
                dataSource: dataSource
            });
}

enter image description here

As shown in picture above, data is not empty but it is not binding data in drop down. How to achieve it? any help would be appreciated.

Upvotes: 1

Views: 1244

Answers (1)

FuatOgme
FuatOgme

Reputation: 141

I think, the problem is your dataTextField & dataValueField declarations. Setting dataSource is not enough. You should declare your dataTextField and dataValueField according to your object properties. In your case it should be like this:

..
dataTextField:"ListName",
dataValueField: "ListID",
..

Upvotes: 2

Related Questions