EXTJS - basic grid blueprint


/ Published in: Other
Save to your folder(s)



Copy this code and paste it in your HTML
  1. /**
  2. * generate a grid, it so commonly used that i decided to make it easy to initiate
  3. */
  4.  
  5. var getNewGrid = function (id, store, columns) {
  6.  
  7. var store = store || new Ext.data.JsonStore({
  8. url: 'get-images.php',
  9. root: 'elements',
  10. fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
  11. });
  12.  
  13. var columns = columns || [
  14. {id: 'name', header: 'Name', sortable: true, dataIndex: 'name'},
  15. {header: 'Modified', width: 120, sortable: true, dataIndex: 'modified'},
  16. {header: 'Type', width: 120, sortable: true, dataIndex: 'type', readOnly: false},
  17. {header: 'Size', width: 120, sortable: true, dataIndex: 'size', align: 'right'}
  18. ]
  19.  
  20. return {
  21. id : id
  22. ,xtype : 'grid'
  23. ,store : store
  24. ,columns : columns
  25. ,autoLoad : false
  26. }
  27. } // eo function
  28.  

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.