Skip to content

Instantly share code, notes, and snippets.

@rattanchauhan
Created July 14, 2017 07:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rattanchauhan/35db263ea5ca88f24803814deaa56652 to your computer and use it in GitHub Desktop.
Save rattanchauhan/35db263ea5ca88f24803814deaa56652 to your computer and use it in GitHub Desktop.
Remote api simulator in Extjs
Ext.define('Example.util.Remote',{
singleton: true,
requires: [
'Ext.ux.ajax.JsonSimlet',
'Ext.ux.ajax.SimManager'
],
constructor: function () {
Ext.ux.ajax.SimManager.init({
defaultSimlet: null
});
},
}, function (U) {
Ext.ux.ajax.SimManager.register({
'/calendars': {
type: 'json',
data: [{
id: 1,
title: 'Title1',
eventStore: {
proxy: {
type: 'ajax',
url: '/Calendars/1'
}
}
}, {
id: 2,
title: 'Title2',
eventStore: {
proxy: {
type: 'ajax',
url: '/Calendars/2'
}
}
}]
},
'/calendars/1': {
type: 'json',
data: function (ctx) {
var data = [
{
id: 1,
startDate: "2017-07-13T18:30:00.000Z",
endDate: "2017-07-13T19:00:00.000Z",
calendarId: 1
},
{
id: 2,
title: "Title",
startDate: "2017-07-10T13:30:00.000Z",
endDate: "2017-07-10T13:20:00.000Z",
calendarId: 1
}
]
return data;
}
},
'/calendars/2': {
type: 'json',
data: function (ctx) {
var data = [
{
id: 5,
title: "Title",
startDate: "2017-07-13T08:30:00.000Z",
endDate: "2017-07-13T09:00:00.000Z",
calendarId: 2
},
{
id:6,
title: "Title",
startDate: "2017-07-13T08:30:00.000Z",
endDate: "2017-07-13T09:00:00.000Z",
calendarId: 2
}
]
return data;
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment