This is a migrated thread and some comments may be shown as answers.

Binding RadComboBox with json array from rest services

0 Answers 105 Views
Documentation and Tutorials
This is a migrated thread and some comments may be shown as answers.
Cesar
Top achievements
Rank 1
Cesar asked on 30 Jul 2015, 07:48 PM

var get​Cars () {
  var serviceUrl = "URL your services";
  var  paramData = {
   
  };

  var req = $.ajax({
    type: 'POST',
    url: serviceUrl,
    contentType: 'application/json; charset=utf-8',

    data: JSON.stringify(paramData ),
    dataType: 'Json',
  });
  req.then(
      function () {
        _console.log("Cars->get​Cars success") : null;
      },
      function () {
        console.log("Cars->getCars failed") : null;
      }
  );
  return req;
}

 

var loadCars = function () {
    var _cboYourControl = $telerik.findComboBox("_cboYourControl");
_cboYourControl .clearItems();
    var req = get​Cars();
    req.success(function (​cars) {
        for (var i = 0; i < ​cars.length; i++) {
            var ​car = ​cars[i];
            var comboItem = new Telerik.Web.UI.RadComboBoxItem();
            comboItem.set_text(​car.​Name);
            comboItem.set_value(car.ID);
            _cboYourControl .trackChanges();
            _cboYourControl .get_items().add(comboItem);
            _cboYourControl .commitChanges();

        }

    });
}

No answers yet. Maybe you can help?

Tags
Documentation and Tutorials
Asked by
Cesar
Top achievements
Rank 1
Share this question
or