ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: queensgambit9 on April 13, 2021, 12:35:57 pm

Title: Modify range values
Post by: queensgambit9 on April 13, 2021, 12:35:57 pm
Would it be possible to modify values used in range condition? Fetching values remotely from DB.

Have values like 'value a, value b' but would like them to be splitted by comma (,) in the filter menu for range condition, ex:

value a, value b becomes:

- value a
- value b

Title: Re: Modify range values
Post by: queensgambit9 on April 13, 2021, 05:41:09 pm
Is there a way to do it in callback in the column definition or is the prefered way to do it in the response from ajax call before values are assigned as options?
Title: Re: Modify range values
Post by: paramvir on April 14, 2021, 11:38:16 am
Quote
Would it be possible to modify values used in range condition?

options displayed in the filter dropdown for range condition can be customized by declaring column.filter.options array or a callback returning an array.
Reference: https://paramquery.com/pro/api#option-column-filter

Also please check "(Shipped - Order) Days" in this example: https://paramquery.com/pro/demos/filter_custom

Quote
Fetching values remotely from DB.

you mean field values displayed in the grid, right?
options displayed in the filter dropdown can be built synchronously ( without separate Ajax request ) from the values displayed in the grid itself ( in case of local or no paging ) by using getDataCascade method.

http://paramquery.com/pro/api#method-getDataCascade
Title: Re: Modify range values
Post by: queensgambit9 on April 14, 2021, 12:24:44 pm
I fetch filter values to populate range condition from DB (select distinct) to get all values and not only them available in grid. Tried using options but can't get it to work.
Seems to work when modifying the response from ajax call to get header options before assigning them.

Instead of equal condition in Range, I would like to use contain condition. Do I need custom override for this? Is there a sample available in that case?

Thanks.
Title: Re: Modify range values
Post by: paramvir on April 14, 2021, 12:42:17 pm
Kindly confirm whether it's local or remote filtering.
Title: Re: Modify range values
Post by: queensgambit9 on April 14, 2021, 12:58:56 pm
Remote.
Title: Re: Modify range values
Post by: paramvir on April 14, 2021, 05:10:36 pm
Quote
Instead of equal condition in Range, I would like to use contain condition. Do I need custom override for this? Is there a sample available in that case?

FilterHelper::_range method can be customized as below:

Code: [Select]
public static function _range($dataIndx, &$fcrule, &$param, $value){
    $arrValue = $value;
    $fcRange = array();
    foreach ($value as $val){
        if ($val == ""){
            //continue;
            FilterHelper::_empty($dataIndx, $fcRange);
        }
        else{
            //$fcRange[] = $dataIndx."= ?";
            $fcrule[] = $dataIndx . " like CONCAT('%', ?, '%')";
            $param[] = $val;
        }
    }
    $fcrule[] = (sizeof($fcRange)>0)? "(". join(" OR ", $fcRange) .")": "";
}