Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. Ext.define('Sandbox.view.OwnersGrid', {
  2. extend: 'Ext.grid.Panel',
  3. requires: ['Sandbox.view.SearchTrigger'],
  4. alias: 'widget.ownersGrid',
  5. store: 'Owners',
  6. columns: [{
  7. dataIndex: 'id',
  8. width: 50,
  9. text: 'ID'
  10. }, {
  11. dataIndex: 'name',
  12. text: 'Name',
  13. items:[{
  14. xtype: 'searchtrigger',
  15. autoSearch: true
  16. }]
  17. },
  18.  
  19. Ext.define('Sandbox.view.SearchTrigger', {
  20. extend: 'Ext.form.field.Trigger',
  21. alias: 'widget.searchtrigger',
  22. triggerCls: 'x-form-clear-trigger',
  23. trigger2Cls: 'x-form-search-trigger',
  24. onTriggerClick: function() {
  25. this.setValue('')
  26. this.setFilter(this.up().dataIndex, '')
  27. },
  28. onTrigger2Click: function() {
  29. this.setFilter(this.up().dataIndex, this.getValue())
  30. },
  31. setFilter: function(filterId, value){
  32. var store = this.up('grid').getStore();
  33. if(value){
  34. store.removeFilter(filterId, false)
  35. var filter = {id: filterId, property: filterId, value: value};
  36. if(this.anyMatch) filter.anyMatch = this.anyMatch
  37. if(this.caseSensitive) filter.caseSensitive = this.caseSensitive
  38. if(this.exactMatch) filter.exactMatch = this.exactMatch
  39. if(this.operator) filter.operator = this.operator
  40. console.log(this.anyMatch, filter)
  41. store.addFilter(filter)
  42. } else {
  43. store.filters.removeAtKey(filterId)
  44. store.reload()
  45. }
  46. },
  47. listeners: {
  48. render: function(){
  49. var me = this;
  50. me.ownerCt.on('resize', function(){
  51. me.setWidth(this.getEl().getWidth())
  52. })
  53. },
  54. change: function() {
  55. if(this.autoSearch) this.setFilter(this.up().dataIndex, this.getValue())
  56. }
  57. }
  58. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement