ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: motoguru on March 19, 2014, 11:19:57 pm

Title: Custom dataType handler ignored by filter methods?
Post by: motoguru on March 19, 2014, 11:19:57 pm
Hello,

I have a custom float field which contains currency format (eg. as a string '123 921.43 USD'). As it's a number not a string, I want to use custom dataType which is in this example:

 colModel[0].dataType = function (val1,val2) {
                val1 = val1.replace(/ /g, '');
                val1 = val1.replace('USD', '');
                val2 = val2.replace(/ /g, '');
                val2 = val2.replace('USD', '');
                val1 = parseFloat(val1);
                val2 = parseFloat(val2);
                if (val1 > val2) return 1;
                if (val1 < val2) return -1;
                return 0;
            };

And it sorts column fine. But filter treats the column as a string and won't filter it well as a float or using custom coparator as seen above. Is there any chance to take column dataType as a comparator method not as a string in filter? Notice I don't want to make this column "float" first and use column render method later.

Thanks in advance
Title: Re: Custom dataType handler ignored by filter methods?
Post by: paramvir on March 20, 2014, 02:34:35 pm
I see what you mean but currently filter can't use the custom comparator function.
Title: Re: Custom dataType handler ignored by filter methods?
Post by: luido on June 13, 2016, 06:15:08 pm
UP on this post.
Is there now a way to have custom datatype (that wont be converted into a string or number before filtering)?
Title: Re: Custom dataType handler ignored by filter methods?
Post by: paramvir on June 13, 2016, 06:28:34 pm
custom dataType ( it's original purpose was for custom sorting ) is not supported and it's not required anymore.

Custom filtering can be done by implementing filter.condition callback.

Example: http://paramquery.com/pro/demos/filter_custom
Title: Re: Custom dataType handler ignored by filter methods?
Post by: luido on June 13, 2016, 06:41:10 pm
When the custom filter is called, cell data is already converted in dataType. In my case, the cell value is a function (a KnockOut observable). So I receive the text definition of the function which I can't filter on. Is there a way to prevent the conversion of the cell value before filtering? (Or to override f.convert)
Or to have a "function" dataType?
Or to have a "preFilter" function that would be called before the cell data is converted?
Title: Re: Custom dataType handler ignored by filter methods?
Post by: paramvir on June 13, 2016, 07:49:44 pm
Any chance of sharing a jsfiddle so that I can look into it?
Title: Re: Custom dataType handler ignored by filter methods?
Post by: luido on June 13, 2016, 08:02:18 pm
I found that by specifying an invalid dataType in the colModel, the cellData isn't converted before filtering. I'd go with that option for now.

Thank you very much!  :)