0

my Devextreme script looks like this :

UmbrellaMobile.Customer = function (params) {

var baseAddress = 'http://localhost/Service/GetCustomers';

var Customers
Customers = function getCustomers() {
    $.ajax({
        url: baseAddress,
        type: 'POST',
        data: '{}',
        dataType: 'json',
        contentType: "application/json; charset=utf-8",
        success: function (res) {
            alert('d');
            console.log("Success");
            console.log(res);

        },
        error: function (res) {
            alert(res);
            console.log("Error! " + res.statusText);
        }
    });
}


var viewModel = {
    Customers: Customers
};

return {
    viewModel: viewModel,
    Customers: Customers
 };

};

upon testing my project, nothing happens. I have set breakpoints with firebug, but I get no errors and nothing else happening.

Can you see where a problem might be?

H_duPreez
  • 37
  • 11

1 Answers1

1

That code will work for you.

UmbrellaMobile.Customer = function(params) {

  var baseAddress = 'http://localhost/Service/GetCustomers';
  var viewModel = {
    Customers: new DevExpress.data.CustomStore({
      load: function() {
        return $.ajax({
          url: baseAddress,
          type: 'POST',
          data: '{}',
          dataType: 'json',
          contentType: "application/json; charset=utf-8",
          success: function(res) {
            console.log("success");
          },
          error: function(res) {
            console.log("error");
          }
        });
      }
    })
  };

  return {
    viewModel: viewModel
  };
};

Please, read more about data layer organization in DevExtreme framework context here and about CustomStore in particular.

seteh
  • 389
  • 4
  • 13
  • Hi @setesh, thanks for your advice. I have tried your solution, and now the compiler tells me that 'Customers' is not defined. what should I do? – H_duPreez Sep 11 '15 at 11:02
  • @H_duPreez show me your code with markup included, please. – seteh Sep 11 '15 at 23:10