cancel
Showing results for 
Search instead for 
Did you mean: 

How to set default filter value in SmartFilter bar - Date field?

Jayakrishnan
Active Participant
0 Kudos

Hi All,

I am working on Custom SAPUI5 Application development using SmartControls. I have used SmartFilter Bar in my application. Date field is one of the filter bar items in the SmartFilter bar.

I need to apply the default value (Last 10 days) in the Smart Filter bar - Date field.

i am not using fiori elements. normal smart controls.

Thanks,

Regards,

Jayakrishnan.

Accepted Solutions (1)

Accepted Solutions (1)

thomas_deubel
Explorer

Hello Jayakrishnan,

use the setFilterData-Method of the SmartFilterBar-Controller. The json data could look something like this:

//Create JSON data that contains the Inital value of the filter
var oDefaultFilter = {
    "PurchaseOrderDate": {
        "conditionTypeInfo": {
            "name": "sap.ui.comp.config.condition.DateRangeType",
            "data": {
                "operation": "LASTDAYS",
                "value1": 10,
                "value2": null,
                "key": "PurchaseOrderDate",
                "calendarType": "Gregorian"
            }
        }
    }
};

//Set SmartFilterBar initial values
oSmartFilterBar.setFilterData(oDefaultFilter);

In this example, PurchaseOrderDate is the ID of the filter field.

For more operations, see e.g following blog: How to use Smart Filter Bar with controlConfiguration conditionType as “DateRangeType”? | SAP Blogs

Regards

Thomas Deubel

Answers (1)

Answers (1)

former_member723794
Participant
0 Kudos

Hi jayakrishnan.chnadramohan,

You need to customize the smart Filter Bar and set the default value for it by using its Id. Check the below code for reference.

<smartFilterBar:ControlConfiguration id="idControlConfigDate"  key="Doj" controlType="date" visibleInAdvancedArea="true"  preventInitialDataFetchInValueHelpDialog="false">       
                            
<smartFilterBar:customData>
<core2:CustomData id="IdSmartDate" key="dateFormatSettings"></core2:CustomData>       
</smartFilterBar:customData>              

</smartFilterBar:ControlConfiguration>

Regards,

Chaitali Pandya

Jayakrishnan
Active Participant
0 Kudos

Hi pandya123 , Thanks for your comments.

I need to maintain the date range type only . you can refer the images i attached with the question. Is it possible with this?

Thanks,

Jayakrishnan.