Advertisement
Guest User

contoh dev express dengan ajax

a guest
Mar 21st, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var dataSource = new DevExpress.data.CustomStore({
  2.                 key: "ID",
  3.                 load: function (loadOptions) {
  4.                     var deferred = $.Deferred(),
  5.                         args = {};
  6.            
  7.                     if (loadOptions.sort) {
  8.                         args.orderby = loadOptions.sort[0].selector;
  9.                         if (loadOptions.sort[0].desc)
  10.                             args.orderby += " desc";
  11.                     }
  12.            
  13.                     args.skip = loadOptions.skip || 0;
  14.                     args.take = loadOptions.take || 12;
  15.            
  16.                     $.ajax({
  17.                         url: "{{ url("api/get/Ms_Country") }}",
  18.                         data: args,
  19.                         success: function(response) {
  20.                             console.log(response);
  21.                             deferred.resolve(response.data, { totalCount: response.totalCount });
  22.                         },
  23.                         error: function() {
  24.                             deferred.reject("Data Loading Error");
  25.                         },
  26.                         timeout: 5000
  27.                     });
  28.            
  29.                     return deferred.promise();
  30.                 },
  31.                 insert :  function(values){
  32.                     return $.ajax({
  33.                         url : "{{ url("api/store/Ms_Country") }}",
  34.                         method : 'POST',
  35.                         data : values
  36.                     });
  37.                 },
  38.                 remove : function(key) {
  39.                     return $.ajax({
  40.                         url: "{{ url("api/destroy/Ms_Country/") }}" + encodeURIComponent(key),
  41.                         method: "DELETE",
  42.                     })
  43.                 },
  44.                 update : function(key, values) {
  45.                     console.log(key);
  46.                     console.log(values);
  47.                     return $.ajax({
  48.                         url: "{{ url("api/update/Ms_Country/") }}" + encodeURIComponent(key),
  49.                         method: "POST",
  50.                         data: values
  51.                     })
  52.                 }
  53.             });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement