xml-grid.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Ext JS Library 2.0 Copyright(c) 2006-2007, Ext JS, LLC. licensing@extjs.com
  3. *
  4. * http://extjs.com/license
  5. */
  6. Ext.onReady(function() {
  7. // create the Data Store
  8. var store = new Ext.data.Store({
  9. // load using HTTP
  10. url : 'sheldon.jsp?_dddc=' + allGetServerTime().getTime(),
  11. url : 'sheldon.xml',
  12. // proxy: new
  13. // Ext.data.ScriptTagProxy({url:'sheldon.jsp'}),
  14. // proxy: new Ext.data.ScriptTagProxy({url:
  15. // 'sheldon.jsp?_dddc='+allGetServerTime().getTime()}),
  16. // proxy: new Ext.data.HttpProxy({url:
  17. // 'sheldon.jsp'}),//...............................
  18. // proxy: new Ext.data.HttpProxy({url: this.url}),
  19. // the return will be XML, so lets set up a reader
  20. reader : new Ext.data.XmlReader({
  21. // records will have an "Item" tag
  22. record : 'Item',
  23. id : 'ASIN',
  24. totalRecords : '@total'
  25. }, [
  26. // set up the fields mapping into the
  27. // xml doc
  28. // The first needs mapping, the others
  29. // are very basic
  30. {
  31. name : 'Author',
  32. mapping : 'ItemAttributes > Author'
  33. }, 'Title', 'Manufacturer', 'ProductGroup'])
  34. });
  35. // create the grid
  36. var grid = new Ext.grid.GridPanel({
  37. store : store,
  38. columns : [{
  39. header : "Author",
  40. width : 120,
  41. dataIndex : 'Author',
  42. sortable : true
  43. }, {
  44. header : "Title",
  45. width : 180,
  46. dataIndex : 'Title',
  47. sortable : true
  48. }, {
  49. header : "Manufacturer",
  50. width : 115,
  51. dataIndex : 'Manufacturer',
  52. sortable : true
  53. }, {
  54. header : "Product Group",
  55. width : 100,
  56. dataIndex : 'ProductGroup',
  57. sortable : true
  58. }],
  59. renderTo : 'example-grid',
  60. width : 540,
  61. height : 200
  62. });
  63. store.load();
  64. });