custom.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. var ds = new Ext.data.Store({
  8. proxy : new Ext.data.ScriptTagProxy({
  9. url : 'http://extjs.com/forum/topics-remote.php'
  10. }),
  11. reader : new Ext.data.JsonReader({
  12. root : 'topics',
  13. totalProperty : 'totalCount',
  14. id : 'post_id'
  15. }, [{
  16. name : 'postId',
  17. mapping : 'post_id'
  18. }, {
  19. name : 'title',
  20. mapping : 'topic_title'
  21. }, {
  22. name : 'topicId',
  23. mapping : 'topic_id'
  24. }, {
  25. name : 'author',
  26. mapping : 'author'
  27. }, {
  28. name : 'lastPost',
  29. mapping : 'post_time',
  30. type : 'date',
  31. dateFormat : 'timestamp'
  32. }, {
  33. name : 'excerpt',
  34. mapping : 'post_text'
  35. }]),
  36. baseParams : {
  37. limit : 20,
  38. forumId : 4
  39. }
  40. });
  41. // Custom rendering Template for the View
  42. var resultTpl = new Ext.XTemplate(
  43. '<tpl for=".">',
  44. '<div class="search-item">',
  45. '<h3><span>{lastPost:date("M j, Y")}<br />by {author}</span>',
  46. '<a href="http://extjs.com/forum/showthread.php?t={topicId}&p={postId}" target="_blank">{title}</a></h3>',
  47. '<p>{excerpt}</p>', '</div></tpl>');
  48. var panel = new Ext.Panel({
  49. applyTo : 'search-panel',
  50. title : 'Forum Search',
  51. height : 300,
  52. autoScroll : true,
  53. items : new Ext.DataView({
  54. tpl : resultTpl,
  55. store : ds,
  56. itemSelector : 'div.search-item'
  57. }),
  58. tbar : ['Search: ', ' ', new Ext.app.SearchField({
  59. store : ds,
  60. width : 320
  61. })],
  62. bbar : new Ext.PagingToolbar({
  63. store : ds,
  64. pageSize : 20,
  65. displayInfo : true,
  66. displayMsg : 'Topics {0} - {1} of {2}',
  67. emptyMsg : "No topics to display"
  68. })
  69. });
  70. ds.load({
  71. params : {
  72. start : 0,
  73. limit : 20,
  74. forumId : 4
  75. }
  76. });
  77. });