This is a migrated thread and some comments may be shown as answers.

toDataSourceRequestString setting undfined

1 Answer 107 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Clifford
Top achievements
Rank 1
Clifford asked on 21 Oct 2019, 04:51 PM

I have a custom column filter for a grid, and when selecting a value, the followingmethod is called

 

public onChange(value: any): void {
 
    const filtersMap: FilterDescriptor[] = value.map(val => ({
      field: this.filterField,
      operator: 'eq',
      val
    }));
 
 
    console.log('ColumnFilterMultiComponent -> filtersMap', JSON.stringify(filtersMap));
 
    const compositeFilter: CompositeFilterDescriptor = {
      logic: 'or',
      filters: filtersMap
    };
 
    this.applyFilter(
      value === '' ?
        this.removeFilter(this.filterField) :
        compositeFilter
    );
  }

 

 

and the resulting DataSourceRequestState object is created:

 

{
    "filter": {
        "logic": "or",
        "filters": [
            {
                "field": "projectStatus",
                "operator": "eq",
                "val": "Active"
            },
            {
                "field": "projectStatus",
                "operator": "eq",
                "val": "Closed"
            }
        ]
    },
    "group": [],
    "skip": 0,
    "sort": [
        {
            "field": "modifiedDate",
            "dir": "desc"
        }
    ],
    "take": 20
}

 

 

but then calling ${toDataSourceRequestString(state)} results in this querystring:

 

filter=(projectStatus~eq~undefined~or~projectStatus~eq~undefined)&page=1&sort=modifiedDate-desc&pageSize=20

 

Why did the values from the filter get changed to undefined?

1 Answer, 1 is accepted

Sort by
0
Clifford
Top achievements
Rank 1
answered on 21 Oct 2019, 04:56 PM

as soon as I posted this I saw that the issue is how I named the parameter when creating the filter. This works:

 

const filtersMap: FilterDescriptor[] = value.map(value => ({
      field: this.filterField,
      operator: 'eq',
      value
    }));
Tags
General Discussions
Asked by
Clifford
Top achievements
Rank 1
Answers by
Clifford
Top achievements
Rank 1
Share this question
or