Binding RadComboBox with json array from rest services

1 posts, 0 answers
  1. Cesar
    Cesar avatar
    3 posts
    Member since:
    Oct 2013

    Posted 30 Jul 2015 Link to this post

    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();

            }

        });
    }

Back to Top