Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Ext.define('Sandbox.view.OwnersGrid', {
- extend: 'Ext.grid.Panel',
- requires: ['Sandbox.view.SearchTrigger'],
- alias: 'widget.ownersGrid',
- store: 'Owners',
- columns: [{
- dataIndex: 'id',
- width: 50,
- text: 'ID'
- }, {
- dataIndex: 'name',
- text: 'Name',
- items:[{
- xtype: 'searchtrigger',
- autoSearch: true
- }]
- },
- Ext.define('Sandbox.view.SearchTrigger', {
- extend: 'Ext.form.field.Trigger',
- alias: 'widget.searchtrigger',
- triggerCls: 'x-form-clear-trigger',
- trigger2Cls: 'x-form-search-trigger',
- onTriggerClick: function() {
- this.setValue('')
- this.setFilter(this.up().dataIndex, '')
- },
- onTrigger2Click: function() {
- this.setFilter(this.up().dataIndex, this.getValue())
- },
- setFilter: function(filterId, value){
- var store = this.up('grid').getStore();
- if(value){
- store.removeFilter(filterId, false)
- var filter = {id: filterId, property: filterId, value: value};
- if(this.anyMatch) filter.anyMatch = this.anyMatch
- if(this.caseSensitive) filter.caseSensitive = this.caseSensitive
- if(this.exactMatch) filter.exactMatch = this.exactMatch
- if(this.operator) filter.operator = this.operator
- console.log(this.anyMatch, filter)
- store.addFilter(filter)
- } else {
- store.filters.removeAtKey(filterId)
- store.reload()
- }
- },
- listeners: {
- render: function(){
- var me = this;
- me.ownerCt.on('resize', function(){
- me.setWidth(this.getEl().getWidth())
- })
- },
- change: function() {
- if(this.autoSearch) this.setFilter(this.up().dataIndex, this.getValue())
- }
- }
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement