1. #11
    Ext User mjoksa's Avatar
    Join Date
    Jun 2007
    Posts
    73
    Vote Rating
    0
    mjoksa is on a distinguished road

      0  

    Default Hello everyone...

    Hello everyone...


    I successfully implemented all fixes mentioned in posts above and everything works fine with filtering.
    I work with C# and use Newtonsoft JSON library for encode/decode data for ExtJS controls.
    I had problem with the way grid filter is sending it data (e.g. filter[0][data][value] and/or something similar so I changed this and grid filter data is now sent JSON encoded to server. Below is my code changes (GridFilter.js):
    Code:
    onBeforeLoad: function(store, options){
        options.params = options.params || {};
    		this.cleanParams(options.params);		
    		//Old way
    //		var params = this.buildQuery(this.getFilterData());
    		
    		//My way :)
    		var params = {
    		    filterData: Ext.encode(this.getFilterData())
    		}; 
    		Ext.apply(options.params, params);
    	},
    ...
    getFilterData: function(){
    		var filters = [],
    			fields  = this.grid.getStore().fields;
    		
    		this.filters.each(function(f){
    			if(f.active){
    				var d = [].concat(f.serialize());
    				//Old way
    //				for(var i=0, len=d.length; i<len; i++)
    //					filters.push({
    //						field: f.dataIndex,
    //						data: d[i]
    //					});
    
                    //My way :)                
    				filters.push({
    					field: f.dataIndex,
    					data: d
    				});
    			}
    		});
    		
    		return filters;
    	},
    On server side I created two classes
    Code:
    public class FilterData
        {
            public string type { get; set; }
            public string value { get; set; }
            public string comparison { get; set; }
        }
    public class GridFilterData
        {
            public string field { get; set; }
            public List<FilterData> data { get; set; }
        }
    so when I JSON decode received grid filter data I get array (list) of GridFilterData objects and I can use LINQ magic to create adequate queries.
    Feel free to use this code changes but I would like them to be implemented (maybe as some config option to chose who to send grid filter data) in new versions of this plugin.

    Cheers

  2. #12
    Ext User
    Join Date
    Apr 2008
    Posts
    57
    Vote Rating
    0
    azbok is on a distinguished road

      0  

    Default


    @mjoksa

    I've done a similar thing to GridFilters in the past, but after I did that, I found the comment for overriding buildQuery. Now I directly use the code provided in that comment. It's generally better off not changing the original code and just doing overrides for custom application changes. That way you don't need to worry about merging when a new version of GridFilters (or whatever you end up changing) comes out.

    Btw the filter[0][data][value] style is for PHP.

  3. #13
    Ext User mjoksa's Avatar
    Join Date
    Jun 2007
    Posts
    73
    Vote Rating
    0
    mjoksa is on a distinguished road

      0  

    Thumbs up 10x

    10x


    @azbok
    10x for input
    I will certainly implement override first thing in the morning.

  4. #14
    Ext User
    Join Date
    Feb 2008
    Location
    Berlin/Germany
    Posts
    97
    Vote Rating
    0
    sabiola is on a distinguished road

      0  

    Default


    Hello,

    Quote Originally Posted by azbok View Post
    I've done a similar thing to GridFilters in the past, but after I did that, I found the comment for overriding buildQuery.
    can you please post a link to this comment?

    Thanks,
    Stefan

  5. #15
    Ext User
    Join Date
    Apr 2008
    Posts
    57
    Vote Rating
    0
    azbok is on a distinguished road

      0  

    Default


    I'm actually using the GridFilter from the svn repo http://extjs-ux.org/repo/trunk, it could be this comment isn't actually in the 0.2.8 package you download from the first post of this thread.

    This is not my comment, this is the comment from the code itself that I have:

    Code:
        /**
         * Function to take structured filter data and 'flatten' it into query parameteres. The default function
         * will produce a query string of the form:
         *              filters[0][field]=dataIndex&filters[0][data][param1]=param&filters[0][data][param2]=param...
         * You can override this function to return json:
         * <pre><code>
         * buildQuery: function(filters) {
         *     var p  = {};
         *     var len  = filters.length;
         *     for(var i=0; i<len; i++) {
         *         var f = filters[i];
         *         if (f.data.comparison) {
         *             if (typeof(p[f.field]) != 'object') {
         *                 p[f.field] = new Object();
         *             }
         *             p[f.field][f.data.comparison] = f.data.value;
         *         } else {
         *             p[f.field] = f.data.value;
         *         }
         *     }
         *     var tmp = {};
         *     tmp["extjs_filter_encoded"] = Ext.util.JSON.encode(p)
         *     return tmp;
         * }
         * </code></pre>

  6. #16
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    5
    mjlecomte will become famous soon enough mjlecomte will become famous soon enough

      0  

    Default


    Maybe we should introduce an "encode" config that will toggle the default buildQuery and that shown in the commentary?

  7. #17
    Ext User
    Join Date
    Apr 2008
    Posts
    57
    Vote Rating
    0
    azbok is on a distinguished road

      0  

    Default


    Quote Originally Posted by mjlecomte View Post
    Maybe we should introduce an "encode" config that will toggle the default buildQuery and that shown in the commentary?
    I think that's an awesome idea, since across the board, people will need to copy/paste the comment into their own overrides and potentially make errors. Certainly if it's built in, there's less errors to be made!

  8. #18
    Ext User
    Join Date
    Feb 2008
    Location
    Berlin/Germany
    Posts
    97
    Vote Rating
    0
    sabiola is on a distinguished road

      0  

    Default


    @mjlecomte:

    Will we get a "new version" bofore the release of 3.0 final?

    Thanks for your work,
    Stefan

  9. #19
    Ext User mjoksa's Avatar
    Join Date
    Jun 2007
    Posts
    73
    Vote Rating
    0
    mjoksa is on a distinguished road

      0  

    Default Some remarks...

    Some remarks...


    @mjlecomte
    As I said in my previous post I am NET Framework user, and I had to change getFilterData method to better suite my needs so please reconsider my code changes for final version and please implement encode option as you mentioned.

    Best regards

  10. #20
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    5
    mjlecomte will become famous soon enough mjlecomte will become famous soon enough

      0  

    Default


    Quote Originally Posted by sabiola View Post
    @mjlecomte:

    Will we get a "new version" bofore the release of 3.0 final?

    Thanks for your work,
    Stefan
    It looks like the version I have won't be available until after 3.0.0 is released.

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar