Related
how to display the following json data ?
i have json data like this, and want to display it in table, i use vue-bostrapt .
Previously I tried like this, but it's not perfect.
this my json
[
{
"id":"1",
"name": "KINTIL",
"desc": "Kintil is good",
"location": [
{
"prov": "Jawa Barat",
"city": "Bandung"
},
{
"prov": "Banten",
"city": "Tanggerang"
}
],
"applied": [
{
"item_name": "galian"
},
{
"item_name": "timbunan"
}
],
"exception": [
{
"ex_name": "F001",
"ex_value": "001001"
},
{
"ex_name": "M001",
"ex_value": "002002"
}
]
}
]
and this html
<b-table class="table spacing-table" style="font-size: 13px;" show-empty
:items="inovasi" :fields="fields" :current-page="currentPage" :per-page="0" :filter="filter" >
</b-table>
and this my script
import json from "../static/data.json";
export default {
name: 'tes',
data() {
return {
inovasi:[],
filter: null,
fields: [
{
key: 'id',
label: 'id',
sortable: true
},
{
key: 'name',
label: 'name',
sortable: true
},
{
key: 'location',
label: 'location',
sortable: true
},
{
key: 'applied',
label: 'applied',
sortable: true
},
{ key: 'actions', label: 'Doc' }
],
currentPage: 0,
perPage: 5,
totalItems: 0
}
},
mounted() {
this.inovasi = json;
},
computed:{
},
methods: {
}
}
this result
how to display location and applied , into a single row table ?
thanks in advance for those who have answered :)
thanks
You can do it using formatter like
fields: [
{
key: 'id',
label: 'id',
sortable: true
},
{
key: 'name',
label: 'name',
sortable: true
},
{
key: 'location',
label: 'location',
sortable: true,
formatter: (value, key, item) => {
return value.map(x => 'prov: ' + x.prov + ' city:' + x.city).join(", ")
}
},
{
key: 'applied',
label: 'applied',
sortable: true,
formatter: (value, key, item) => {
return value.map(x => x.item_name).join(", ")
}
},
{ key: 'actions', label: 'Doc' }
],
It will show for the location column this: prov: Jawa Barat city:Bandung, prov: Banten city:Tanggerang and for the applied column this: galian, timbunan
I need to initial grid which will showed only 10 records, although it is more, the rest should be hidden, for example there will be a button under grid which on click, will display all the rest. Prompt way as it can be implemented. P.S. : extjs 5.0.1
Two ways of doing this. First is to specifically set a property on each record to say that it should be hidden initially, then use a filter on the store to ensure they are not shown:
Ext.application({
name : 'Fiddle',
launch : function() {
var store = Ext.create('Ext.data.Store', {
storeId:'simpsonsStore',
fields:['name', 'email', 'phone', 'hidden'],
data:{'items':[
{ 'name': 'Lisa', "email":"lisa#simpsons.com", "phone":"555-111-1224", hidden: false },
{ 'name': 'Bart', "email":"bart#simpsons.com", "phone":"555-222-1234", hidden: false },
{ 'name': 'Homer', "email":"homer#simpsons.com", "phone":"555-222-1244", hidden: true },
{ 'name': 'Marge', "email":"marge#simpsons.com", "phone":"555-222-1254", hidden: true }
]},
proxy: {
type: 'memory',
reader: {
type: 'json',
rootProperty: 'items'
}
},
filters: [{ property: 'hidden', value: false }]
});
Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
columns: [
{ text: 'Name', dataIndex: 'name' },
{ text: 'Email', dataIndex: 'email', flex: 1 },
{ text: 'Phone', dataIndex: 'phone' }
],
height: 200,
width: 400,
renderTo: Ext.getBody(),
bbar: [{
xtype: 'button',
text: 'Show All Rows',
handler: function() {
store.clearFilter();
}
}]
});
}
});
Another approach is to filter on the index of the items in the store:
Ext.application({
name : 'Fiddle',
launch : function() {
var store = Ext.create('Ext.data.Store', {
storeId:'simpsonsStore',
fields:['name', 'email', 'phone', 'hidden'],
data:{'items':[
{ 'name': 'Lisa', "email":"lisa#simpsons.com", "phone":"555-111-1224", hidden: false },
{ 'name': 'Bart', "email":"bart#simpsons.com", "phone":"555-222-1234", hidden: false },
{ 'name': 'Homer', "email":"homer#simpsons.com", "phone":"555-222-1244", hidden: true },
{ 'name': 'Marge', "email":"marge#simpsons.com", "phone":"555-222-1254", hidden: true }
]},
proxy: {
type: 'memory',
reader: {
type: 'json',
rootProperty: 'items'
}
}
});
store.addFilter([
function(item) {
return store.indexOf(item) <= 1;
}
]);
Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
columns: [
{ text: 'Name', dataIndex: 'name' },
{ text: 'Email', dataIndex: 'email', flex: 1 },
{ text: 'Phone', dataIndex: 'phone' }
],
height: 200,
width: 400,
renderTo: Ext.getBody(),
bbar: [{
xtype: 'button',
text: 'Show All Rows',
handler: function() {
store.clearFilter();
}
}]
});
}
});
Here we use the indexOf method on the store instance to filter out anything past index 1 in the store.
Hi I need to display data in a grid, using a servlet and passing data to the servlet in POST, the server send back to extjs a valid Json but the gridd remain empty, this is my code:
Ext.onReady(function() {
//Ext.direct.Manager.addProvider(Ext.app.REMOTING_API);
//added model inside onready
Ext.define('PvInfo', {
extend: 'Ext.data.Model',
fields: ['potenziale','fax','cliente','titolare','pv_id','mail','sito','cod_mmas', 'ragione_sociale', 'indirizzo', 'cap','comune','provincia','telefono','codice_fiscale']
});
//separated store into unique var for guaranteeRange
var store = Ext.create('Ext.data.Store', {
pageSize: 50,
model: 'PvInfo',
autoLoad: true,
listeners :
{
load : function(store)
{
Ext.getCmp('numRow').setText("Numero Anagrafiche: "+store.getCount());
console.debug("store");
console.debug(store);
}
},
proxy: {
idProperty: 'pv_id',
type: 'ajax',
url: 'http://localhost:8080/MyFirstServlet/GreetingServlet',
reader:
{
type: 'json',
root: 'selections',
successProperty: 'success'
},
actionMethods: {
create: 'POST', read: 'POST', update: 'POST', destroy: 'POST'
},
extraParams: {selections:selection_string, task: 'pv_list'}
}
});
console.debug(store);
//funzione per recuperare i parametri get
//create the grid
var grid = Ext.create('Ext.grid.Panel', {
// height: 450,
// width: 700,
layout:'fit',
title: 'Elenco Anagrafiche ',
store: store,
emptyText:'nessun record presente',
columns: [
{dataIndex:'pv_id',
flex:1.1,
text:"id",
hidden:true
},
{
dataIndex: 'cod_mmas',
flex: 1,
text: 'codice MMAS'
},
{
dataIndex:'potenziale',
flex: 1.5,
text:'potenziale mmas'
},
{
dataIndex: 'ragione_sociale',
flex: 2.5,
text: 'Ragione Sociale'
}, {
dataIndex: 'indirizzo',
flex: 3,
text: 'Indirizzo'
}, {
dataIndex: 'cap',
flex: 1.3,
text: 'Cap'
},{
dataIndex: 'comune',
flex:1.3,
text: 'Comune'
},{
dataIndex:'provincia',
flex:1.1,
text:'Provincia'
},{
dataIndex:'telefono',
flex:1.1,
text:'Telefono'
},{
dataIndex:'codice_fiscale',
flex:1.1,
text: 'Codice Fiscale/Partita IVA'
},
{
dataIndex:'titolare',
flex:1,
text:'Titolare',
hidden:true
},
{
dataIndex:'fax',
flex:1,
text:'Fax',
hidden:true
},
{
dataIndex:'cliente',
flex:0.3,
text:'cliente',
hidden:true
}
//'codice mmas', 'ragione sociale', 'indirizzo', 'cap','comune','provincia','telefono','cf/piva'
],
// toolbar
tbar: {
items: [{
xtype: 'label',
x:100,
id:'numRow',
text: 'Numero Anagrafiche:'
}
]
}
,
listeners:
{
itemdblclick: function(dv, record, item, index, e)
{ console.log(record);
//alert('working'+record.data.pv_id);
menuContext.showAt(e.xy);
},
itemclick: function(view, record, item, index, e, options)
{
menuContext.showAt(e.xy);
}
},
renderTo: Ext.getBody()
});
menuContext = new Ext.menu.Menu({
items: [{
id: 'do-something',
text: 'Visualizza anagrafica',
handler: function()
{
var selection = grid.getView().getSelectionModel().getSelection()[0];
console.log("selection.data");
console.debug(selection.data);
var f= Ext.create('Ext.form.Panel',
{
frame: true,
width: 640,
bodyPadding: 5,
//renderTo: 'form-example',
fieldDefaults:
{
labelAlign: 'left',
labelWidth: 90,
anchor: '100%'
},
items:
[
{
xtype: 'hiddenfield', //1
name: 'id',
},
{
xtype: 'displayfield', //2
name: 'codice_mmas',
fieldLabel: 'Codice MMAS',
value: selection.data.cod_mmas
},
{
xtype: 'textfield', //3
name: 'cod_cliente',
fieldLabel: 'Codice Cliente',
},
{
xtype: 'textfield', //4
name: 'ragione_sociale',
fieldLabel: 'Ragione Sociale',
value:selection.data.ragione_sociale
},
{
xtype: 'textfield', //5
name: 'titolare',
fieldLabel: 'Titolare',
value: selection.data.titolare
},
{
xtype: 'textfield', //8
name: 'codice_fiscale',
fieldLabel: 'Cod. Fis./P. IVA',
value: selection.data.codice_fiscale
},
{xtype:'textfield',
name:'potenziale_mmas',
fieldLabel:"Potenziale MMAS",
value: selection.data.potenziale
},
{
xtype: 'checkboxfield', //11
name: 'cliente',
fieldLabel: 'cliente',
//boxLabel: 'box label'
value: selection.data.cliente
},
{
xtype:'textfield',
name:'indirizzo',
fieldLabel:'indirizzo',
value:selection.data.indirizzo},
{xtype:'textfield',
name:'mail',
fieldLabel:'mail',
value:selection.data.mail
},
{
xtype: 'textfield', //12
name: 'provincia',
fieldLabel: 'Provincia',
value:selection.data.provincia
},
{
xtype: 'textfield', //13
name: 'comune',
fieldLabel: 'comune',
value: selection.data.comune
},
{
xtype: 'textfield', //14
fieldLabel: 'cap',
name:'cap',
value:selection.data.cap
},
{
xtype:'textfield',
fieldLabel:'telefono',
name:'telefono',
value: selection.data.telefono
},
{
xtype: 'textfield', //15
fieldLabel: 'fax',
name:'fax',
value:selection.data.fax
},
{
xtype:'textfield',
fieldLabel:'sito',
name:'sito',
value:selection.data.sito
}
]
});
var w = new Ext.Window(
{
height: 470, width: 650,
title:"scheda Anagrafica di "+selection.data.ragione_sociale,
items:[f]
});
w.show();
w.center();
}//end function di handler
}],
});
});
this is the json produced by the servlet:
{
"results":[
{
"potenziale":"59",
"cap":"11100",
"indirizzo":"x",
"pv_id":"35",
"telefono":"x",
"provincia":"AO",
"ragione_sociale":"x",
"cod_mmas":"35",
"cliente":"0",
"titolare":"x",
"comune":"AOSTA"
},
{
"potenziale":"26",
"cap":"11100",
"indirizzo":"x",
"pv_id":"50",
"telefono":"016532590",
"provincia":"AO",
"ragione_sociale":"x",
"cod_mmas":"50",
"cliente":"0",
"titolare":"x",
"comune":"AOSTA"
},
{
"potenziale":"68.75",
"cap":"11100",
"indirizzo":"x",
"pv_id":"56",
"telefono":"x",
"provincia":"AO",
"ragione_sociale":"x",
"cod_mmas":"56",
"codice_fiscale":"x",
"cliente":"0",
"titolare":"x",
"comune":"AOSTA"
},
{
"potenziale":"39",
"cap":"11100",
"indirizzo":"x68",
"pv_id":"63",
"telefono":"x",
"provincia":"AO",
"ragione_sociale":"xSRL",
"cod_mmas":"63",
"cliente":"0",
"titolare":"x",
"comune":"AOSTA"
},
{
"potenziale":"26",
"cap":"11027",
"indirizzo":"x",
"pv_id":"68",
"telefono":"x",
"provincia":"AO",
"ragione_sociale":"xPATRIZIA",
"cod_mmas":"68",
"cliente":"0",
"titolare":"xPATRIZIA",
"comune":"SAINT VINCENT"
},
{
"potenziale":"42",
"cap":"11013",
"indirizzo":"x 75",
"pv_id":"2819",
"telefono":"x",
"provincia":"AO",
"ragione_sociale":"x",
"cod_mmas":"2819",
"codice_fiscale":"x3",
"cliente":"0",
"titolare":"x",
"comune":"COURMAYEUR"
},
{
"potenziale":"valore non disponibile",
"cap":"11020",
"indirizzo":"LOC.LA PLACE,23",
"pv_id":"3427",
"telefono":"x",
"provincia":"AO",
"ragione_sociale":"x",
"cod_mmas":"3427",
"codice_fiscale":"x",
"cliente":"0",
"comune":"ISSOGNE"
},
{
"potenziale":"valore non disponibile",
"cap":"11026",
"indirizzo":"x2",
"pv_id":"3994",
"telefono":"x",
"provincia":"AO",
"ragione_sociale":"x",
"cod_mmas":"3994",
"codice_fiscale":"x",
"cliente":"0",
"comune":"x"
}
]
}
I am new to extjs so I do not know what I am doing wrong,can you indicate my mistake? thanks in advance.
You proxy's reader defines the data root as selections:
reader:
{
type: 'json',
root: 'selections',
successProperty: 'success'
},
Whereas your json doesn't have such node, it has results instead.
Change the root to results and it should work.
I have the following problem, I can not fetch the data from the sublist, I am doing wrong?
my code:
//file lstCabDet.txt
{"root":[
{
"NumeroPedido":"0000000001",
"CodigoCliente":"100000",
"NombreCliente":"hskjdnd",
"NIF":"43065236",
"Detalle":[{
"DocumentoVenta":"0000000001",
"Posicion":"000010",
"CodigoMaterial":"000000000010000002",
"Material":"Prueba material 1"}]},
{
"NumeroPedido":"0000000002",
"CodigoCliente":"100000",
"NombreCliente":"hskdsnb",
"NIF":"43065236",
"Detalle":[{
"DocumentoVenta":"0000000002",
"Posicion":"000010",
"CodigoMaterial":"000000000010000002",
"Material":"Prueba material 1"}]
}]}
//Model
Ext.regModel('listaDocumentosModel', {
fields: [
{name: 'NumeroPedido', type: 'string'},
{name: 'CodigoCliente', type: 'string'},
{name: 'NombreCliente', type: 'string'},
{name: 'NIF', type: 'string'}
],
associations:[
{type: 'hasMany',
model: 'listaDocumentoDetalleModel', name: 'listaDocumentoDetalleModel'}
]
});
Ext.regModel('listaDocumentoDetalleModel',
{
fields:[
{name: 'DocumentoVenta', type: 'string'},
{name: 'Posicion', type: 'string'},
{name: 'CodigoMaterial', type: 'string'},
{name: 'Material', type: 'string'}
],
associations:[
{type: 'belongsTo', model: 'listaDocumentosModel'}
]
});
//Store
var listaDocumentosStore = new Ext.data.Store (
{
autoLoad: true,
model: 'listaDocumentosModel',
proxy:
{
id: 'listaDoc',
type: 'rest',
url: 'data/lstCabDet.txt',
reader:
{
type: 'json',
root : 'root'
}
}
});
//View Detail
var disDetDoc =
'<div>'+
'<div>'+
'<div>{NumeroPedido}</div>'+
'<div>{Posicion}</div>'+
'<div>{CodigoMaterial}</div>'+
'<div>{Material}</div>'
'</div>'+
'</div>';
detalleDocumento = Ext.extend(Ext.Panel,
{
layout: 'card',
initComponent: function()
{
this.dockedItems = [
{
xtype: 'toolbar',
dock: 'top',
title: 'Detalle documento',
items: [
{
ui: 'back',
text: 'Volver',
scope: this,
handler: function()
{
this.ownerCt.setActiveItem(this.prevCard,
{
type: 'slide',
reverse: true,
scope: this,
after: function()
{
this.destroy();
}
});
}
}]
}];
this.detalleDocPanel = new Ext.Panel(
{
layout: 'fit',
items: [
{
scroll: 'vertical',
data: this.record.data,
tpl: disDetDoc
}]
});
this.items = this.detalleDocPanel;
detalleDocumento.superclass.initComponent.call(this);
}
});
Ext.reg('detalleDocumento', detalleDocumento);
//View Master
var listDoc =
'<div class="materialItem">'+
'<div class="list-codigo">'+
'{NumeroPedido}'+
'{CodigoCliente}'+
'{NIF}'+
'{NombreCliente}'+
'</div>'
'</div>';
var lblRef = [{
xtype: 'fieldset',
defaults:
{
labelAlign: 'left',
labelWidth: '30%'
},
items: [
{
xtype: 'textfield',
label: 'Referencia',
useClearIcon: true
}]
}];
var buttonVolver = [{
ui: 'back',
text: 'Volver',
handler: function()
{
window.open("consultaDoc.html","_self");
}
},
{
xtype: 'spacer'
}
]
var dockedItems = [{
xtype: 'toolbar',
title: 'Lista de documentos',
dock: 'top',
ui: 'dark',
items: buttonVolver
}]
listaDocumentoView = Ext.extend(Ext.Panel,
{
fullscreen: true,
layout: 'card',
initComponent: function()
{
this.lDoc = new Ext.List({
id: 'listaDoc',
grouped: false,
itemTpl: listDoc,
loadingText: false,
store: listaDocumentosStore
});
this.lDoc.on('selectionchange', this.onSelect, this);
this.listaDocumentosPanel = new Ext.Panel(
{
layout: 'fit',
dockedItems: dockedItems,
items: this.lDoc,
listeners:
{
activate:
{
fn: function()
{
this.lDoc.getSelectionModel().deselectAll();
Ext.repaint();
},
scope: this
}
}
});
this.items = this.listaDocumentosPanel;
listaDocumentoView.superclass.initComponent.call(this);
},
onSelect: function(selectionmodel, records)
{
if (records[0] !== undefined)
{
var detalleDocCard = new detalleDocumento(
{
prevCard: this.listaDocumentosPanel,
record: records[0]
});
this.setActiveItem(detalleDocCard, 'slide');
}
}
});
Ext.reg('listaDocumentoView', listaDocumentoView);
I`m dealing with the same issue. Maybe this help you to get closer to a solution:
In Accessing nested objects in JSON feed - Sencha Touch answer:
Ext.regModel('MODEL', {
fields: [{name:'position', mapping:'NIF.postion'}]
});
Change your model to
Ext.regModel('listaDocumentosModel', {
fields: [
{name: 'NumeroPedido', type: 'string'},
{name: 'CodigoCliente', type: 'string'},
{name: 'NombreCliente', type: 'string'},
{name: 'NIF', type: 'string'}
],
hasMany:[
{ model: 'listaDocumentoDetalleModel', name: 'listaDocumentoDetalleModel', , associationKey: 'listaDocumentoDetalleModel'}
]});
and remove this line from sub-model
associations:[
{type: 'belongsTo', model: 'listaDocumentosModel'}
]
This modifications solve my same problem, hope this helps to you
My grid isnt showing data when put to tab. This grid, store, model, JSON are working when renderd to body or div, or as a part of a viewport. Only not showing when put in tab, that is also created using JSON and Tree! This is a (sometimes)working example. I cant figure it out, maybe scope bug ... Please help!
Ext.Loader.setConfig({ enabled: true });
Ext.require(['*']);
Ext.require('app.kontakt');
Ext.require('app.ponude');
Ext.require('app.gridStore');
Ext.onReady(function() {
Ext.create('Ext.Viewport', {
layout: {
type: 'border',
padding: 5
},
defaults: {
split: true
},
items: [{
region: 'north',
collapsible: false,
split: true,
height: 60
},{
region: 'west',
collapsible: false,
title: 'IZBORNIK',
split: true,
width: 200,
layout: 'fit',
items:[
myTree
]
},{
region: 'center',
layout: 'fit',
border: false,
items: [{
xtype:'tabpanel',
id:'mainTabPanel'
}]
}]
});
});
var store = Ext.create('Ext.data.TreeStore', {
proxy: {
type: 'ajax',
url: 'app/myTree.json',
},
reader: {
type: 'ajax',
root: 'nodes',
record: 'leaf'
}
});
var myTree = Ext.create('Ext.tree.Panel', {
store: store,
rootVisible: false,
border: false,
listeners:{
itemclick: function(view,record,item,index,e){
if(record.isLeaf() && record.raw.tabCls){
var tabId=record.raw.tabId;
var mainPanel = Ext.getCmp('mainTabPanel');
var existingTab = Ext.getCmp(tabId);
if(existingTab){
mainPanel.setActiveTab(existingTab);
}else{
mainPanel.add(Ext.create(record.raw.tabCls,{id:tabId})).show();
}
}
}
}
});
Ext.define("app.kontakt",{
extend:"Ext.panel.Panel",
name:"kontakt",
title:"Kontakt",
layout:"border",
closable:true,
border: false,
items:[
{
region: 'north',
collapsible: false,
split:true,
layout:"fit",
height: 100,
border: false,
buttons: [{
text: 'Load1',
handler:function(){
myStore.load({
scope : this,
url : 'app/kontaktGrid.json'
});
}
},{
text: 'Load2',
handler:function(){
myStore.load({
scope : this,
url : 'app/kontaktGrid1.json'
});
}
}]
},{
region: "center",
xtype:"grid",
id:"kontaktGrid",
layout: "fit",
store: myStore,
border: false,
columns: [
{header: 'name', dataIndex: 'name',flex:1},
{header: 'email', dataIndex: 'email', flex:1},
{header: 'phone', dataIndex: 'phone', flex:1}
]
}
]
});
Ext.define('app.gridStore', {
extend: 'Ext.data.Model',
fields: [
'name', 'email', 'phone'
]
});
var myStore =Ext.create('Ext.data.Store', {
model: 'app.gridStore',
proxy: {
type: 'ajax',
url : '',
reader:{
type:'json',
root: 'items'
}
},
autoLoad:false
});
JSON for TREE
{
children: [
{ text:"KLIJENTI", expanded: true,
children: [{ text:"Kontakt", leaf: true , tabId : "tab1", tabCls: "app.kontakt"}]
}
]
}
JSON for GRID
{'items':[
{"name":"Lisa", "email":"lisa#simpsons.com", "phone":"555-111-1224"},
{"name":"Bart", "email":"bart#simpsons.com", "phone":"555--222-1234"}
]}
ok... i have tes your code just by copy paste to my firebug (of course with edit the json urls),
and i got an error.... This is because the program flow...
if it was your script, and put them in a single file, you specify a grid before the store
here code works for me no error...
Ext.onReady(function () {
Ext.create('Ext.Viewport', {
layout: {
type: 'border',
padding: 5
},
defaults: {
split: true
},
items: [{
region: 'north',
collapsible: false,
split: true,
height: 60
}, {
region: 'west',
collapsible: false,
title: 'IZBORNIK',
split: true,
width: 200,
layout: 'fit',
items: [myTree]
}, {
region: 'center',
layout: 'fit',
border: false,
items: [{
xtype: 'tabpanel',
id: 'mainTabPanel'
}]
}]
});
});
var store = Ext.create('Ext.data.TreeStore', {
proxy: {
type: 'ajax',
url: 'myTree.json',
},
reader: {
type: 'ajax',
root: 'nodes',
record: 'leaf'
}
});
var myTree = Ext.create('Ext.tree.Panel', {
store: store,
rootVisible: false,
border: false,
listeners: {
itemclick: function (view, record, item, index, e) {
if (record.isLeaf() && record.raw.tabCls) {
var tabId = record.raw.tabId;
var mainPanel = Ext.getCmp('mainTabPanel');
var existingTab = Ext.getCmp(tabId);
if (existingTab) {
mainPanel.setActiveTab(existingTab);
} else {
mainPanel.add(Ext.create(record.raw.tabCls, {
id: tabId
})).show();
}
}
}
}
});
Ext.define('app.gridStore', {
extend: 'Ext.data.Model',
fields: ['name', 'email', 'phone']
});
var myStore = Ext.create('Ext.data.Store', {
model: 'app.gridStore',
proxy: {
type: 'ajax',
url: '',
reader: {
type: 'json',
root: 'items'
}
},
autoLoad: false
});
Ext.define("app.kontakt", {
extend: "Ext.panel.Panel",
name: "kontakt",
title: "Kontakt",
layout: "border",
closable: true,
border: false,
items: [{
region: 'north',
collapsible: false,
split: true,
layout: "fit",
height: 100,
border: false,
buttons: [{
text: 'Load1',
handler: function () {
myStore.load({
scope: this,
url: 'grid.json'
});
}
}, {
text: 'Load2',
handler: function () {
myStore.load({
scope: this,
url: 'grid1.json'
});
}
}]
}, {
region: "center",
xtype: "grid",
id: "kontaktGrid",
layout: "fit",
store: myStore,
border: false,
columns: [{
header: 'name',
dataIndex: 'name',
flex: 1
}, {
header: 'email',
dataIndex: 'email',
flex: 1
}, {
header: 'phone',
dataIndex: 'phone',
flex: 1
}]
}]
});