in my case, i want, if click the button "drilldown" chart load new data from another Json. This is my Store
Ext.define('DWP3.store.konten.Coba', {
extend: 'Ext.data.Store',
alias: 'store.coba',
storeId: 'coba',
uses: [
'Ext.data.Store'
],
fields: [
{name: 'periode'},
{name: 'Teknik'},
],
proxy: {
type: 'ajax',
url : 'resources/data/load2.php',
reader: {
type: 'json',
rootProperty: 'view_sum1'
}
},
autoLoad: true,
});
}
i want load the new data also from json which converted from mySQL. i want load this one :
newData : function(){
var store = Ext.create('Ext.data.Store', {
fields: [
{name: 'periode'},
{name: 'prodi'},
],
proxy: {
type: 'ajax',
url : 'resources/data/load3.php', //from another load in php
reader: {
type: 'json',
rootProperty: 'view_sum2' // another root
}
},
autoLoad: true,
});
return store;
}
i call the function like this in my chart.js:
{
text:'Test',
handler:function(){
this.down('cartesian').getStore().newData();
}
}
in this case i want if click the button my store load new data but from another Json which converted from mySQL. it is possible to do that?or do you have any solution from my case?
I would advice you to declare your 2nd store the same way you did with the first one. And simply load it inside the handler of your drilldown :
handler : function() {
Ext.getStore('your new store ID').load();
}
But I'm not really sure what you really want, your question isn't clear to me.
Related
i have this store. my problem, i want get data from this Json.
Ext.define('DWP.store.Test', {
extend: 'Ext.data.Store',
fields: [
{name: 'field1'},
{name: 'field2'},
],
proxy: {
type: 'ajax',
url : 'resources/data/load.php',
reader: {
type: 'json',
rootProperty: 'root'
}
},
autoLoad: true,
});
i tried this code to get the data from Json, but not worked. how can i get data from json?
var json = Ext.encode(Ext.pluck(store.data.items, 'store'));
Since you have autoLoad: true this should looks like:
var store = Ext.getStore('DWP.store.Test');
store.each(function (record, id) {
console.log(record.get('field1'));
});
if you prefer autoLoad: false this looks like:
var store = Ext.getStore('DWP.store.Test');
store.load({
callback: function (records, operation, success) {
store.each(function (record, id) {
console.log(record.get('field1'));
});
}
});
I have a clasic store
Ext.define('xxx.store.Search', {
extend: 'Ext.data.Store',
model: 'xxx.model.Search',
requires: ['xxx.data.xxxx'],
proxy:
{
type: 'xxxxx',
digSearchUrl: {
initRequest: 'ajax/xxx/xxx/xx',
pollRequest: 'ajax/xxxx/xxxx/xxxxxx'
}
},
autoLoad: false,
defaultSortDirection: 'DESC'
});
Now i usually do a store load like this:
this.getStore('Search').load({
digSearchCfg: {
xxx: sid,
xxx: xxxx
}
});
I know i could use the standard approch like in here:
Attempting to load Ext store with JSON data from AJAX request returns error
But i would rather define the error handler in the store it self. is that possible?
If you would like to catch and handle the Ajax request exceptions yourself just add a Exception listener to the Ajax proxy, like so:
var store = Ext.create('Ext.data.JsonStore', {
storeId: 'simpsonsStore',
fields: ['name', 'email', 'phone'],
autoLoad: true,
proxy: {
type: 'ajax',
url: 'data2.json',
reader: {
type: 'json',
rootProperty: 'characters'
},
listeners: {
exception: function(proxy, response, operation, eOpts ) {
console.log("EXCEPTION CAUGHT!");
}
}
},
listeners: {
load: function() {
console.log(this);
}
}
});
You can see a demo fiddle here. data1.json will work and will log the store object to console. data2.json will log 'EXCEPTION CAUGHT!' to the console.
Here is the documentation for the Ajax proxy for reference.
I'am working on a ExtJS 4.2 Project, where i want to use a Paging Toolbar to navigate through Images.
When i open the Window, all Images are correct, but when i click on the next button to see the next Images, the result is empty. Its because the Parameter Id isn't passed to the backend System.
I saw in other Threads an option like baseParams but they are not in the documentation and don't work.
//My Store Class
Ext.define('App.store.Images', {
extend: 'Ext.data.Store',
model: 'App.model.Images',
autoLoad: false,
autoSync: false,
storeId: 'Images',
pageSize: 8,
proxy: {
type: 'ajax',
url: '/getImages',
reader: {
type: 'json',
root: 'images',
totalProperty: 'total'
}
}
});
// This code is execute when i open the Window
var imagesStore = Ext.StoreManager.get('Images');
imagesStore.on('load', buildContent);
imagesStore.load({
params: {
id: record.get('id'),
start: 0,
limit: 8
}
});
Where can be additional Parameter be defined?
In fact you can define extraParams on the store proxy. You can do this just before the load method call :
Ext.apply(store.getProxy().extraParams, {
'yourId': yourId
});
or in your proxy config :
proxy: {
type: 'ajax',
url: '/getImages',
reader: {
type: 'json',
root: 'images',
totalProperty: 'total'
}
extraParams: {
'yourId': yourId
}
}
I created a store, where I'm loading nested data from .json file:
var userStore = Ext.create('Ext.data.Store', {
model: 'User',
storeId:'2013',
autoLoad: true,
pageSize: 4,
proxy: {
type: 'ajax',
url: 'data/users.json',
reader: {
type: 'json',
root: 'users',
totalProperty: 'total'
},
writer: {
type: 'json'
}
}
});
To add any new data to grid I use:
var asdfg = Ext.getStore(myNewGrid);
asdfg.add({lastname: nowa, firstname: nowa2);
Everything works fine until I refreshed the page. After it I lose all changes.
My model 'User' file:
Ext.define('MyApp.controller.Users', {
extend: 'Ext.app.Controller',
border: false,
views: [
'user.List'
],
init: function() {
this.control({
'viewport > panel': {
render: this.onPanelRendered
}
});
},
onPanelRendered: function() {
console.log('The panel was rendered');
}});
Is it any simple way to save and commit my new changes similar to loading? To start my web use Sencha Cmd v.4.0.4
just use autoSync:true in your store.
in that case adding type:rest to your proxy will make it easier.
look at this example: http://dev.sencha.com/deploy/ext-4.0.1/examples/restful/restful.html
This is my code:
Ext.define('gridOptionsModel', {
extend: 'Ext.data.Model'
});
var gridOptionsStore = Ext.create('Ext.data.JsonStore', {
autoDestroy: true,
model: 'gridOptionsModel',
proxy: {
type: 'ajax',
actionMethods: 'POST',
url: '/application.php?way=system&case=updateFields41',
extraParams: {meta: 'true'},
reader: {
type: 'json',
root: 'gridoptions'
}
}
});
And this is the part where it reloads the data from the url but does not send the desired parameters
gridOptionsStore.load({proxy: {
extraParams: {gridData: grid.getState()}}
});
I have tried everything possible but cannot made it to POST the gridData parameter.
you can add the extra param before the load.
gridOptionsStore.getProxy().extraParams.gridData = grid.getState();
gridOptionsStore.load();
This works for me.
instead of setting a property directly, use a method when available:
gridOptionsStore.getProxy().setExtraParam('gridData', grid.getState());