Web Interface For Lite Argus Control modules
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.6 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*!
  2. * Ext JS Library 3.3.1
  3. * Copyright(c) 2006-2010 Sencha Inc.
  4. * licensing@sencha.com
  5. * http://www.sencha.com/license
  6. */
  7. Ext.onReady(function(){
  8. var ds = new Ext.data.Store({
  9. proxy: new Ext.data.ScriptTagProxy({
  10. url: 'http://extjs.com/forum/topics-remote.php'
  11. }),
  12. reader: new Ext.data.JsonReader({
  13. root: 'topics',
  14. totalProperty: 'totalCount',
  15. id: 'post_id'
  16. }, [
  17. {name: 'title', mapping: 'topic_title'},
  18. {name: 'topicId', mapping: 'topic_id'},
  19. {name: 'author', mapping: 'author'},
  20. {name: 'lastPost', mapping: 'post_time', type: 'date', dateFormat: 'timestamp'},
  21. {name: 'excerpt', mapping: 'post_text'}
  22. ])
  23. });
  24. // Custom rendering Template
  25. var resultTpl = new Ext.XTemplate(
  26. '<tpl for="."><div class="search-item">',
  27. '<h3><span>{lastPost:date("M j, Y")}<br />by {author}</span>{title}</h3>',
  28. '{excerpt}',
  29. '</div></tpl>'
  30. );
  31. var search = new Ext.form.ComboBox({
  32. store: ds,
  33. displayField:'title',
  34. typeAhead: false,
  35. loadingText: 'Searching...',
  36. width: 570,
  37. pageSize:10,
  38. hideTrigger:true,
  39. tpl: resultTpl,
  40. applyTo: 'search',
  41. itemSelector: 'div.search-item',
  42. onSelect: function(record){ // override default onSelect to do redirect
  43. window.location =
  44. String.format('http://extjs.com/forum/showthread.php?t={0}&p={1}', record.data.topicId, record.id);
  45. }
  46. });
  47. });