FlexFilter Odata changing $filter value

Posted by: lic on 7 January 2024, 4:37 am EST

  • Posted 7 January 2024, 4:37 am EST

    Hi. I’m using Odata, have column “Formats”.

    <wj-flex-grid-column-group header="Formats" binding="Formats" [editor]="formatsMultiSelect">
        <ng-template wjFlexGridCellTemplate cellType="Cell" [cellType]="'Cell'" let-item="item">
            {{item.Formats?.join(', ')}}
        </ng-template>
    </wj-flex-grid-column-group>

    When appling filter on this column I need to send to Odata “$filter” value like this with changed column name/binding.

    $filter: ((WareFormatEntityDetails/FormatCode eq 'HYPER'))
  • Posted 7 January 2024, 6:18 pm EST

    Hi,

    You can refer to the below sample that uses the approach of extending the RestCollectionView Class to create a custom class that can communicate with the OData. The advantage of this approach would be that you may modify any request before sending it to the server.

    Please refer to this DEMO sample: https://developer.mescius.com/wijmo/demos/Core/CollectionView/RestCollectionView/OData/angular

    *Please update the “_asODataValueFilter()” method in “rest-collection-view-odata.ts” file as follows:

    fld = this._asODataValue(col.header),
    [line 186]

    Now the filter query will contain the Column’s header instead of binding for all the columns.*

    Also, just in case, if you are not able to use the above approach of extending RestCollectionView class then you may override the _asODataValueFilter() method of ODataCollectionView class.

    Please refer to this sample for reference: https://stackblitz.com/edit/angular-ivy-seccw1

    Regards

  • Posted 7 January 2024, 6:21 pm EST

    Hi

    You may put the desired conditional check as follows in the _asODataValue() method:

            if(col.binding === "Formats")
                fld =this._asODataValue("WareFormatEntityDetails/FormatCode");

    Regards

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels