Get Free Trial

How to set date interval for custom data server?

Answered
Oleg asked on August 25, 2021

In our app we have buttons and calendar for date selection. How we can change date interval of report data? I can’t find how I can pass start date and end date to report. 
There is customField property. I added them

customFields: [
{
name: 'Start Date',
value: '1231241',
},
{
name: 'End Date',
value: '2231241',
},
],

but they doesn’t go to custom server while flexmonster pivot making requests. 
There is “interval” in Field Object but it’s not clear how to pass date interval there. Documentation is scarce. 

9 answers

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster August 25, 2021

Hello,
 
Thank you for reaching out to us.
 
We suggest using filters to control what interval is covered by your report. It is achievable using the Date Query Object associated with the desired hierarchy.
For example, if you want to only display records within the specific interval based on the “Date” field, it should be defined as the following:

"uniqueName": "Date",
"filter": {
"query": {
"between": [
"2019-08-06",
"2019-10-04"
]
}
}

 
Here is a JSFiddle demonstrating this approach: https://jsfiddle.net/flexmonster/uwdvnrc3/.
 
You can also configure filters using UI. Use the gear icon placed on each header to open the filtering pop-up. If the clicked field corresponds to the date data type, the “DATES” tab will appear. Open it to choose the desired condition and values.
 
You can also use custom controls (mentioned buttons and calendar) to configure the desired Filter Object. In this case, use the setFilter method to apply the configuration to the chosen field.
 
Please let us know if it helps.
We are looking forward to your feedback.
 
Kind regards,
Illia

Public
Oleg August 26, 2021

And is it possible to filter report data without “Date” field? That is say we have report without date type field and we want to filter data from custom data server by date? 

Public
Vera Didenko Vera Didenko Flexmonster August 26, 2021

Hello, Oleg,
 
Thank you for your response.
 
For such cases, we recommend using the customizeAPIRequest hook.
This way, you could pass the dates to filter by along with the requests and filter the data on your server before sending the response to Flexmonster.
 
Please let us know if this helps.
 
Kind regards,
Vera

Public
Oleg August 26, 2021

Vera and Illia, thank you!

Public
Oleg August 26, 2021

Please update @types/flexmonster for customizeApiRequest field support

Public
Vera Didenko Vera Didenko Flexmonster August 27, 2021

Hello, Oleg,

Thank you for your reply.

We moved the TypeScript definitions from @types/flexmonster to the flexmonster module.
All up-to-date type definitions can be found inside the node_modules/flexmonster/types/flexmonster.d.ts file.
For more details, please see https://www.flexmonster.com/doc/integration-with-typescript/#!type-definitions.
You are welcome to check out how types are referenced in our Typescript React sample project on GitHub for guidance: https://github.com/flexmonster/pivot-react/tree/master/typescript.
 
In addition, here is an example of how you can use customizeAPIRequest as an initialization parameter in React Typescript:

<FlexmonsterReact.Pivot
ref={this.pivotRef}

customizeAPIRequest={req => {
req["requestHeaders"] = {
"customHeader1": "This is the first custom request header",
"customHeader2": "This is the second custom request header"
};
return req
}}

report={{...}}
/>

 
We have noticed that customizeAPIRequest is present in the initialization parameter types yet missing in the property types. 
Our team will update the type definitions, and the update will be available in the upcoming minor release of Flexmonster with the ETA 6th of September.
In the meantime, to use customizeAPIRequest as an API call, please refer to it in the following way:

this.flexmonster["customizeAPIRequest"]((req:object) => {
req["requestHeaders"] = {
"customHeader1": "This is the first custom request header",
"customHeader2": "This is the second custom request header"
};
return req
})

 

Please let us know if this helps.

Kind regards,
Vera

Public
Oleg August 27, 2021

Thank you

Public
Vera Didenko Vera Didenko Flexmonster September 6, 2021

Hello, Oleg,
 
We are happy to inform you that the type definition for customizeAPIRequest() was added to the property types.
This is provided in the 2.9.7 version of Flexmonster: https://www.flexmonster.com/release-notes/.
 
You are welcome to update the component: https://www.flexmonster.com/doc/updating-to-the-latest-version/.
 
Please let us know if the fix works fine for you.
 
Kind regards,
Vera

Public
Vera Didenko Vera Didenko Flexmonster 7 days ago

Hello, Oleg,
 
How are you?
 
We are wondering if the updated type definitions work fine for you.
Did updating to the latest version resolve the issue with the customizeAPIRequest type missing?
 
Please let us know if everything works.
Looking forward to your reply.
 
Kind regards,
Vera

Please login or Register to Submit Answer