Hello,
I'm trying to use Flexmonster to visualize and update some data through the drillthrough view by setting the editing: true configuration.
I tried to follow instructions from:
Hope my example is clear enough.
(For more context: the idea is to view and balance the workload of different users)
Hello, Sophie,
Thank you for reaching out to us and for providing examples.
When a cell value is edited through Flexmonster, the changes are kept in memory and are not applied to the data set. With this in mind, checking the cell value on the datachanged event, applying the necessary changes to your data set, and using the updateData() API call to refresh the data in Flexmonster is the recommended way. As for updating only one particular field instead of the whole record, currently, all fields of the record need to be provided.
However, there seems to be an issue with the editing feature. Our team will need some time to investigate this case in more detail and we will share the results with the ETA 11th of January.
Please let us know if this would work fine for you. In the meantime, feel free to contact us if any questions arise.
Kind regards,
Vera
Hello, thanks for your reply.
I think I have a rough understanding by now of how things work.
However, I'd like to point out some inconsistent behaviours, as illustrated in the following http://jsfiddle.net/soso/ewunc4pf:
So right now, the solution I came up with is:
That doesn't seem like the most efficient approach. So my follow-up questions would be:
To answer your question, with my current workaround, I don't need an immediate fix, but definitely any help or fix will be appreciated.
Hello, Sophie,
Thank you for your reply.
As for basic editing in the drill-through being reflected in the main pivot table but not in the report's dataSource
:
Our team would like to confirm that this is the expected behavior. Flexmonster is designed for analyzing and visualizing existing data; therefore, it is not intended for Flexmonster to edit the underlying data set. Still, Flexmonster offers a broad API reference allowing to implement an editing feature/scenario around Flexmonster.
Regarding the remaining points, please see our answers and suggestions below:
Yes, in your custom popup, you could display a second Flexmonster instance using the flat
layout. Aside from editing cells in the drill-through view, you can also edit cells directly on the grid in the flat
layout.
With this in mind, our team suggests the following approach for implementing the edit feature:
Step 1: Disable the editing
option and the drill-through view on the main pivot table.
Step 2: When a grid cell is double-clicked, display a second Flexmonster instance in flat form in your own custom popup with the editing
option enabled. We will use this Flexmonster instance for editing the data.
This leads us to your next question: "How can I retrieve my source of truth for the data (getReport().dataSource.data
is simple but hacky)".
As mentioned in the beginning, Flexmonster is not designed for editing the underlying data set since it focuses on analyzing and visualizing existing data.
Therefore, for your case, we recommend using the updateData()
API call only for reloading the data in Flexmonster from your server (once the data set is updated on your server). Our team suggests the following solution for applying the changes to the data set:
Step 3: Attach a handler for the datachanged
event to the second Flexmonster instance (the one inside your custom popup from Step 2).
Step 4: Once the datachanged
event fires, apply the change to your data set outside of Flexmonster (for example, on your server).
Step 5: After the change is applied in your data set (on your server), reload the updated data set from your server in Flexmonster with the updateData()
API call (without the partial
option) to reflect the changes.
updateData()
and editable: true
behave consistently?
It seems the root cause of the issue you are facing is the issue with duplicating tuples. If tuples are not repeated, the editable: true
option and the datachanged
event should work correctly and, as a result, this will remove the need for the second Flexmonster instance (in the custom pop-up). Our team is currently working on a solution for this issue, and we will return to you with updates with the ETA 11th of January.
We hope this helps. You are welcome to contact us if further questions arise.
Kind regards,
Vera
Hello, Sophie,
We are happy to inform you that our team fixed the drillThrough edit inconsistencies. Now the issue with duplicate tuples when using the editing feature is fixed. Also, the issue with the unnecessary "datachanged"
event triggering was fixed, so now the "datachanged"
event will trigger only once when a record is edited.
This is available in the latest (2.9.16) minor release version of Flexmonster.
You are welcome to update the component. Here is our updating to the latest release version guide for assistance: https://www.flexmonster.com/doc/updating-to-the-latest-version/.
Please let us know if the fix works well for you.
Kind regards,
Vera
Hello, Sophie,
Hope you're having a great week!
Just checking in to ask if you've had a chance to test out the mentioned fix. Is everything working well on your side?
We'd be happy to hear your feedback.
Kind regards,
Vera
Hello Vera,
I was able to verify (in one of my submitted fiddles http://jsfiddle.net/soso/ewunc4pf) that datachanged
event now seems to trigger correctly.
I didn't test things too thoroughly though, as in the final implementation (React) I went with an alternate editing table, and I am managing the reference data in a React state (outside of Flexmonster, as you suggested).
Still, I think the fact that editable: true
and partial update (which I didn't use in the end) could deserve some precisions in the documentation, since, for instance, we don't know what the "Save report" button will actually save (unless we keep track of changes externally and call a full updateData
before saving the report to disk)
Hello, Sophie,
Thank you for the update.
We are happy to hear that the datachanged
event is working well and that the solution with an alternate editing table worked for you.
Regarding the editable: true
usage details with calling updateData()
, thank you for your feedback. Our documentation team will consider it in our documentation updates and improvements.
As always, should any questions arise, feel free to reach out to us.
Kind regards,
Vera
Hello again, I wasn't sure if I should open another ticket or stay in the new one, but I decided to post another problem I found, as it's related.
I implemented the logic discussed above in our real application which uses React.
Upon changing the reference data in a parent component, the data is updated in Flexmonster.
But whenever the data is changed, we're getting the following error from Flexmonster in the developer console:
Uncaught TypeError: Cannot read properties of null (reading 'element')
at new k (flexmonster.full.js:99:1)
at h.Fe (flexmonster.full.js:1572:1)
at flexmonster.full.js:1561:1
k @ flexmonster.full.js:99
Fe @ flexmonster.full.js:1572
(anonyme) @ flexmonster.full.js:1561
requestAnimationFrame (asynchrone)
requestAnimationFrame @ flexmonster.full.js:149
u.$n.load.ON @ flexmonster.full.js:1559
load @ flexmonster.full.js:86
h @ flexmonster.full.js:1559
k @ flexmonster.full.js:2365
PivotApi @ flexmonster.full.js:2383
(anonyme) @ flexmonster.full.js:2393
(anonyme) @ index.js:1
invokePassiveEffectCreate @ react-dom.development.js:23487
callCallback @ react-dom.development.js:3945
invokeGuardedCallbackDev @ react-dom.development.js:3994
invokeGuardedCallback @ react-dom.development.js:4056
flushPassiveEffectsImpl @ react-dom.development.js:23574
unstable_runWithPriority @ scheduler.development.js:468
runWithPriority$1 @ react-dom.development.js:11276
flushPassiveEffects @ react-dom.development.js:23447
(anonyme) @ react-dom.development.js:23324
workLoop @ scheduler.development.js:417
flushWork @ scheduler.development.js:390
performWorkUntilDeadline @ scheduler.development.js:157
The implementation of the component looks roughly as below (the actual code is more complex).
The code is actually more complex, and may contain errors, but my first question here would be more to know how to debug the problem on my side. And to find out if this
import React, { useEffect, useRef, useState } from 'react';
import { FlexmonsterReference, Pivot } from 'react-flexmonster/hooks';
// Illustration - Actual code may differ
const MyComponent: React.FC<any> = ({
licenseKey,
data,
config,
localization,
}) => {
const flexmonsterRef = useRef<FlexmonsterReference>(null);
const [report, setReport] = useState<any>([]);
useEffect(() => {
const x = {
...config,
localization,
dataSource: { data },
}
setReport(x);
}, [data, config, localization]);
// none of these are triggered
const handleDataError = (params: any) => console.log('dataerror', params);
const handleLocalizationError = () => console.log('localizationerror');
const handleQueryError = () => console.log('queryerror');
return (
<Pivot
ref={flexmonsterRef}
licenseKey={licenseKey}
report={report}
dataerror={handleDataError}
localizationerror={handleLocalizationError}
queryerror={handleQueryError}
/>
);
};
This question is now closed