Results 1 to 1 of 1

Thread: ExtJS not using my filter override

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha User
    Join Date
    Aug 2016
    Posts
    1

    Default ExtJS not using my filter override

    Hello, I have a project in which I needed to make a custom grid date filter.
    Everything work fine until the stateful save. I need to add a custom value to the state.I overrode the getState method from a class that extends Ext.util.Filter :

    PHP Code:
    Ext.define('RelativeDateUtilFilter', {    extend'Ext.util.Filter',


        
    getState: function () {
            var 
    config this.getInitialConfig(),
                
    result = {},
                
    name;


            for (
    name in config) {
                
    // We only want the instance properties in this case, not inherited ones,
                // so we need hasOwnProperty to filter out our class values.
                
    if (config.hasOwnProperty(name)) {
                    
    result[name] = config[name];
                }
            }


            
    delete result.root;
            
    result.value this.getValue();
            
    result.relValue this.relValue;


            
    this.callParent();


            return 
    result;
        }
    }); 
    I have an override of the filter base class to make it use my own util filter :

    PHP Code:
    createFilter: function (configkey) {
            var 
    filter = new RelativeDateUtilFilter(this.getFilterConfig(configkey));
            
    filter.isGridFilter true;
            return 
    filter;
        } 
    The problem is, my getState in the RelativeDateUtilFilter class is only called when I created the filter for the first time. When ExtJS saves the state it uses the one in the base class Ext.util.Filter. I can sort of workaround by putting my code directly in the Ext.util.Filter class, but i don't want to since it is not good in case i want to upgrade for example.

    Any help is appreciated !

    EDIT :


    In case this ever helps someone, I fixed this by removing my RelativeDateUtilFilter class and my filter base override, and putting my getState method in an override file :


    PHP Code:
    Ext.define('Override.util.Filter', {
        
    override :'Ext.util.Filter',
        
    getState: function () {
            var 
    config this.getInitialConfig(),
                
    result = {},
                
    name;
            for (
    name in config) {
                if (
    config.hasOwnProperty(name)) {
                    
    result[name] = config[name];
                }
            }
            
    delete result.root;
            
    result.value this.getValue();
            if(
    this.relValue) {
                
    result.relValue this.relValue;
            }
            return 
    result;
        }}); 
    (in a /overrides/util/Filter,js file, so it is loaded correctly by SenchaCMD)
    Last edited by spotom; 5 Oct 2016 at 9:19 PM. Reason: Added Answer

Similar Threads

  1. How to change filter encoding / override json proxy?
    By pablotcarreira in forum Sencha Architect 2.x: Help & Discussions
    Replies: 9
    Last Post: 9 Dec 2017, 2:34 AM
  2. Ext.PagingToolbar with Filter Window using Ext.ux.grid.RowEditor (override)
    By jorgelive in forum Ext 3.x: User Extensions and Plugins
    Replies: 1
    Last Post: 16 Nov 2010, 4:58 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •