Ext.onReady(function() { var myData = [ ['3m Co', 71.72, 0.02, 0.03, '9/1 12:00am'], ['Alcoa Inc', 29.01, 0.42, 1.47, '9/1 12:00am'], //.................. ['Verizon Communications', 35.57, 0.39, 1.11, '9/1 12:00am'], ['Wal-Mart Stores, Inc.', 45.45, 0.73, 1.63, '9/1 12:00am'] ]; var store = Ext.create('Ext.data.ArrayStore', { fields: ['company','price','change','pctChange','lastChange'], data: myData }); Ext.create('Ext.grid.Panel', { store: store, columns: [ { text : 'Company', dataIndex: 'company' }, { text : 'Price', dataIndex: 'price' }, { text : 'Change', dataIndex: 'change' }, { text : '% Change', dataIndex: 'pctChange' }, { text : 'Last Updated', dataIndex: 'lastChange' } ], height: 350, width: 600, title: ' grid', renderTo: 'grid1' }); });
<!DOCTYPE html> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="stylesheet" href="/resources/css/ext-all.css" type="text/css" /> <script src="/ext-all.js" type="text/javascript"></script> <script src="/examples/grid1.js" type="text/javascript"></script> </head> <body> <p> grid Ext.data.ArrayStore</p> <div id="grid1"></div> </body> </html>
Ext.require([ 'Ext.grid.*', 'Ext.data.*', ]);
Ext.onReady(function() { var myData = [ { company: 'Alcoa Inc', price: 71.72, change: 0.02, pctChange: 0.03, lastChange: '9/1 12:00am' }, { company: 'Altria Group Inc', price: 83.81, change: 0.28, pctChange: 0.34, lastChange: '9/1 12:00am' }, { company: 'American International Group, Inc.', price: 81.82, change: 0.12, pctChange: 0.63, lastChange: '9/1 12:00am' } ]; var store = Ext.create('Ext.data.Store', { fields: ['company','price','change','pctChange','lastChange'], data: myData }); var grid = Ext.create('Ext.grid.Panel', { store: store, columns: [ { text : 'Company', dataIndex: 'company' }, { text : 'Price', dataIndex: 'price' }, { text : 'Change', dataIndex: 'change' }, { text : '% Change', dataIndex: 'pctChange' }, { text : 'Last Updated', dataIndex: 'lastChange' } ], height: 350, width: 600, title: ' grid', renderTo: 'grid2' }); });
Ext.onReady(function() { var myData = [ { company: 'Alcoa Inc', price: 71.72, change: 0.02, pctChange: 0.03, lastChange: '9/1 12:00am' }, { company: 'Altria Group Inc', price: 83.81, change: 0.28, pctChange: 0.34, lastChange: '9/1 12:00am' }, { company: 'American International Group, Inc.', price: 81.82, change: 0.12, pctChange: 0.63, lastChange: '9/1 12:00am' } ]; Ext.define('Model', { extend: 'Ext.data.Model', fields: ['company','price','change','pctChange','lastChange'] }); var store = Ext.create('Ext.data.Store', { model: 'Model', data: myData }); var grid = Ext.create('Ext.grid.Panel', { store: store, columns: [ { text : 'Company', dataIndex: 'company' }, { text : 'Price', dataIndex: 'price' }, { text : 'Change', dataIndex: 'change' }, { text : '% Change', dataIndex: 'pctChange' }, { text : 'Last Updated', dataIndex: 'lastChange' } ], height: 350, width: 600, title: ' grid', renderTo: 'grid3' }); });
Ext.onReady(function() { Ext.define('myModel', { extend: 'Ext.data.Model', fields: ['company','price','change','pctChange','lastChange'] }); var store = Ext.create('Ext.data.Store', { model: 'myModel', proxy: { type: 'ajax', url: '/examples/data/data.json', reader: { type: 'json', root: 'data' } }, autoLoad: true }); var grid = Ext.create('Ext.grid.Panel', { store: store, columns: [ { text : 'Company', dataIndex: 'company' }, { text : 'Price', dataIndex: 'price' }, { text : 'Change', dataIndex: 'change' }, { text : '% Change', dataIndex: 'pctChange' }, { text : 'Last Updated', dataIndex: 'lastChange' } ], height: 350, width: 600, title: ' grid', renderTo: 'grid4' }); });
var store = Ext.create('Ext.data.Store', { model: 'myModel', pageSize: 50, proxy: { type: 'ajax', url: '/examples/data/data.json', reader: { type: 'json', root: 'data' } }, autoLoad: true });
var grid = Ext.create('Ext.grid.Panel', { store: store, columns: [ { text : 'Company', dataIndex: 'company' }, { text : 'Price', dataIndex: 'price' }, { text : 'Change', dataIndex: 'change' }, { text : '% Change', dataIndex: 'pctChange' }, { text : 'Last Updated', dataIndex: 'lastChange' } ], height: 350, width: 600, title: ' grid', renderTo: 'grid5', bbar: Ext.create('Ext.PagingToolbar', { store: store }) });
Ext.onReady(function() { Ext.define('myModel', { extend: 'Ext.data.Model', fields: ['company','price','change','pctChange','lastChange'] }); var store = Ext.create('Ext.data.Store', { model: 'myModel', proxy: { type: 'ajax', url: '/examples/data/data.json', reader: { type: 'json', root: 'data' } }, autoLoad: true, remoteSort: true }); var grid = Ext.create('Ext.grid.Panel', { store: store, columns: [ { text : 'Company', dataIndex: 'company' }, { text : 'Price', dataIndex: 'price' }, { text : 'Change', dataIndex: 'change' }, { text : '% Change', dataIndex: 'pctChange' }, { text : 'Last Updated', dataIndex: 'lastChange' } ], height: 350, width: 600, title: ' grid', renderTo: 'grid6', bbar: Ext.create('Ext.PagingToolbar', { store: store }) }); });
Ext.Loader.setPath('Ext.ux', '/public/ux'); Ext.require([ 'Ext.ux.grid.FiltersFeature', ]); Ext.onReady(function() { Ext.define('myModel', { extend: 'Ext.data.Model', fields: ['company','price','change','pctChange','lastChange'] }); var store = Ext.create('Ext.data.Store', { model: 'myModel', proxy: { type: 'ajax', url: '/public/examples/data/data.json', reader: { type: 'json', root: 'data' } }, autoLoad: true, remoteSort: true }); var filters = { ftype: 'filters', encode: true, local: false }; var grid = Ext.create('Ext.grid.Panel', { store: store, features: [filters], columns: [ { text : 'Company', dataIndex: 'company', filter: { type: 'string' } }, { text : 'Price', dataIndex: 'price', filter: { type: 'int' } }, { text : 'Change', dataIndex: 'change', filter: { type: 'float' } }, { text : '% Change', dataIndex: 'pctChange', filter: { type: 'float' } }, { text : 'Last Updated', dataIndex: 'lastChange', filter: { type: 'date' } } ], height: 350, width: 600, title: ' grid ', renderTo: 'grid8', bbar: Ext.create('Ext.PagingToolbar', { store: store }) }); });
Ext.Loader.setPath('Ext.ux', '/public/ux'); Ext.require([ 'Ext.ux.grid.FiltersFeature', ]);
var filters = { ftype: 'filters', encode: true, local: false };
filter: { type: 'string' }
fields: [ {name: 'weight', type: 'int'}, {name: 'company', type: 'string'}, {name: 'price', type: 'float'}, {name: 'change', type: 'float'}, {name: 'pctChange', type: 'float'}, {name: 'lastChange', type: 'string'} ]
Ext.create('Ext.data.Store', { pageSize: 10, model: 'myModel', proxy: { type: 'ajax', url: '/examples/data/data2.json', actionMethods: { read: 'POST' }, reader: { type: 'json', root: 'data', totalProperty: 'totalCount' } }, autoLoad: true, remoteSort: true });
{ text : '% Change', flex:1, dataIndex: 'pctChange' },
store: Ext.data.StoreManager.lookup('gridStore'),
renderer: function(value){ if(value > 75){ value = '<span style="color:#ff0000;">' + value + '</span>'; } else { value = '<span style="color:#00ff00;">' + value + '</span>'; } return value; }
bbar: Ext.create('Ext.PagingToolbar', { store: store, displayInfo: true, displayMsg: 'Displaying topics {0} - {1} of {2}', emptyMsg: "No topics to display" })
Ext.Loader.setPath('Ext.ux', '/ux'); Ext.require([ 'Ext.ux.grid.FiltersFeature', ]); Ext.onReady(function() { Ext.define('myModel', { extend: 'Ext.data.Model', fields: [ {name: 'weight', type: 'int'}, {name: 'company', type: 'string'}, {name: 'price', type: 'float'}, {name: 'change', type: 'float'}, {name: 'pctChange', type: 'float'}, {name: 'lastChange', type: 'string'} ] }); Ext.create('Ext.data.Store', { pageSize: 10, model: 'myModel', proxy: { type: 'ajax', url: '/examples/data/data2.json', actionMethods: { read: 'POST' }, reader: { type: 'json', root: 'data', totalProperty: 'totalCount' } }, autoLoad: true, remoteSort: true }); var filters = { ftype: 'filters', encode: true, local: false }; var grid = Ext.create('Ext.grid.Panel', { store: Ext.data.StoreManager.lookup('gridStore'), features: [filters], columns: [ { text : 'Weight', dataIndex: 'weight', width: 50, sortable: false, filter: { type: 'int' } }, { text : 'Company', dataIndex: 'company', flex:1, filter: { type: 'string' } }, { text : 'Price', dataIndex: 'price', flex:1, renderer: function(value){ if(value > 75){ value = '<span style="color:#ff0000;">' + value + '</span>'; } else { value = '<span style="color:#00ff00;">' + value + '</span>'; } return value; } }, { text : 'Change', flex:1, dataIndex: 'change' }, { text : '% Change', flex:1, dataIndex: 'pctChange' }, { text : 'Last Updated', flex:1, dataIndex: 'lastChange', filter: { type: 'date' } } ], height: 350, width: 600, title: ' ...', renderTo: 'grid9', bbar: Ext.create('Ext.PagingToolbar', { store: store, displayInfo: true, displayMsg: 'Displaying topics {0} - {1} of {2}', emptyMsg: "No topics to display" }) }); });
Source: https://habr.com/ru/post/169125/
All Articles