Передать элемент ошибки в источник данных кендо

Я использую один источник данных для нескольких элементов кендо. Есть ли простой способ, как я могу передать элемент ошибки в dataSource, где ошибка может быть показана, если она возникает?

var countryDataSource = new kendo.data.DataSource({
  transport: {
    read: function (options) {     
      $.ajax({
        url: utils.createUrl("codelist/GetCountries"),
        success: function (result) {
          // notify the data source that the request succeeded
          options.success(result);
        },
        error: function (response) {
          // notify the data source that the request failed
          // that.displayError(alertContainer, response.status.toString() + "[" + response.statusText + "]");
          options.error(response);
        }
      });
    }
  }
});

$("[data-id=loadingLocationCountry]").kendoDropDownList({
  autoBind: false,
  // how can I pass error element e.g. countryDataSource($(errorElement)))
  dataSource: countryDataSource 
});    

$("[data-id=unloadingLocationCountry]").kendoDropDownList({
  autoBind: false,
  dataSource: countryDataSource
});       

Я придумал только это решение, но новый источник данных создается для каждого использования (новый экземпляр)

var countryDataSource = function(errorContainer) {
   return new kendo.data.DataSource({
      ....
      error: function (response) {
      // notify the data source that the request failed
      that.displayError(that.errorContainer, response.status.toString() + "[" + response.statusText + "]");
      options.error(response);
    }
   });
}

$("[data-id=loadingLocationCountry]").kendoDropDownList({
  ..
  dataSource: countryDataSource($("[data-id=loadingCountryErrorContainer]")) 
});  

0 ответов

Другие вопросы по тегам