Ext.grid.Panel

柔光的暖阳◎ 2022-08-14 01:39 202阅读 0赞

Basic GridPanel

Code Editor

Live Preview

Select Code

  1. Ext.create('Ext.data.Store', {
  2. storeId:'simpsonsStore',
  3. fields:['name', 'email', 'phone'],
  4. data:{
  5. 'items':[
  6. { 'name': 'Lisa', "email":"lisa@simpsons.com", "phone":"555-111-1224" },
  7. { 'name': 'Bart', "email":"bart@simpsons.com", "phone":"555-222-1234" },
  8. { 'name': 'Homer', "email":"home@simpsons.com", "phone":"555-222-1244" },
  9. { 'name': 'Marge', "email":"marge@simpsons.com", "phone":"555-222-1254" }
  10. ]},
  11. proxy: {
  12. type: 'memory',
  13. reader: {
  14. type: 'json',
  15. root: 'items'
  16. }
  17. }
  18. });
  19. Ext.create('Ext.grid.Panel', {
  20. title: 'Simpsons',
  21. store: Ext.data.StoreManager.lookup('simpsonsStore'),
  22. columns: [
  23. { header: 'Name', dataIndex: 'name' },
  24. { header: 'Email', dataIndex: 'email', flex: 1 },
  25. { header: 'Phone', dataIndex: 'phone' }
  26. ],
  27. height: 200,
  28. width: 400,
  29. renderTo: Ext.getBody()
  30. });

The code above produces a simple grid with three columns. We specified a Store which will load JSON data inline. In most apps we would be placing the grid inside another container and wouldn’t need to use the height, width and renderTo configurations but they are included here to make it easy to get up and running.

The grid we created above will contain a header bar with a title (‘Simpsons’), a row of column headers directly underneath and finally the grid rows under the headers.

dockedItems : Object/ Object[]

A component or series of components to be added as docked items to this panel. The docked items can be docked to either the top, right, left or bottom of a panel. This is typically used for things like toolbars or tab bars:

  1. var panel = new Ext.panel.Panel({ dockedItems: [{ xtype: 'toolbar', dock: 'top', items: [{ text: 'Docked to the top' }] }] });

引用自:http://docs.sencha.com/extjs/4.1.0/#!/api/Ext.grid.Panel-cfg-dockedItems

发表评论

表情:
评论列表 (有 0 条评论,202人围观)

还没有评论,来说两句吧...

相关阅读