PDA

View Full Version : [UNKNOWN][3.??] Broken "filter" param handling in GridFilters



stalek
6 Jan 2010, 4:18 AM
I have 6 params on my DirectStore. When any filter is not enabled (I use JSON encoding feature) the "onBeforeLoad" method removes "filter" parameter from parameters list and it's not reconstructed/added later in "buildQuery" method.

Because of this I receive exception "Parameter count mismatch." during call. It's because "filter" parameter is missing (has been removed from parameters list). The method called by DirectPrivider (.net version) has such signature:


public MessageResult GetMessages(long start, long limit, string sort, string dir, string filter, string clientAppId)

I was trying to avoid the problem adding method with overloaded parameters list like below, but DirectAction object uses Dictionary to store info about method names for methods it can call so we can't create two methods with the same name but with different parameters list.



[DirectMethod]
// There is NO filter parameter here !!!
public MessageResult GetMessages(long start, long limit, string sort, string dir, string clientAppId)
{
return GetMessages(start, limit, sort, dir,null, clientAppId);
}

Temporary I resolved the problem modifying the condition at the end of "buildQuery" method in GridFilters.js file.

The old version was like this:



// only build if there is active filter
if (tmp.length > 0){
p[this.paramPrefix] = Ext.util.JSON.encode(tmp);
}

My new version has "else" clause like in the code below:


// only build if there is active filter
if (tmp.length > 0){
p[this.paramPrefix] = Ext.util.JSON.encode(tmp);
}
else
p[this.paramPrefix] = null;


Maybe somebody knows better solution...

It worked quite well with version 3.0 (then I received null value on "filter" parameter and order and amount of parameters was proper).

I don't see significant changes in GridFilters.js file between versions 3.0 and 3.1 ...