Oracle Apex 18.1 Interactive Grid (IG) Setting fil

2020-03-05 02:49发布

问题:

Is there a way to set filters for an IG in Oracle Apex via an Javascript or PL/SQL API?

Doing my research i stumbled across APEX IG Cookbook for 5.1.4 or some Blogposts How to hack APEX interactive grid series for customizing IGs with Javascript. So setting filters similar to the PL/SQL APEX_IR.ADD_FILTER Proceedure where you can set filters for an interactive Report (IR) the column name, operator and filter value should be possible.

I figured out the name of the internal tables, where the filters are stored if they're set (APEX_APPLICATION_PAGE_IR_COND for IR Filters and APEX_APPL_PAGE_IG_RPT_FILTERS for IG) but don't really know if that's helpful.

With apex.region("StaticRegionID").widget().toolbar("findElement","search_field").val("SearchTextValue"); apex.region("StaticRegionID").widget().interactiveGrid("getActions").invoke("search"); it is possible to set the Searchvalue and execute the search action but it isn't possible to set the operator/Filter type (EQ, NEQ, LT, LTE, GT,GTE, LIKE, NLIKE, N, NN, C, NC, IN, NIN)

So far i haven't found a good way to customize the search action in libaries\apex\widget.interactiveGrid.js or to set the right parameter before invoking the search action in order to add the filters.

Does anyone know how to do this?

回答1:

I just solved my problem. There is an Method called addFilter inside the libaries\apex\widget.interactiveGrid.js which can be simply called with a filter object and a options object as parameter. This is really useful when combined with the values from other Inputfields.

Example:

apex.region("YourStaticRegionID").widget().interactiveGrid("addFilter", {
  type: 'column',
  columnType: 'column',
  columnName: 'YourColumnName',
  operator: 'EQ',
  value: $v2('P2_NEW'),
  isCaseSensitive: false
});

The $v2 API is used in the example above to get the search term the user typed in a Text Input Field called P2_NEW.