Custom Data Source (CDS) hierarchy-level field cannot be pre-selected in Rows/Columns on initial load, only drag-and-drop places it

Answered
Oladipo asked 4 days ago

Flexmonster version: 2.9.134 (checked 2.9.135 changelog, but no relevant fix)

 

Summary:
We have a date field exposed through the Custom Data Source API as a Year › Quarter › Month › Day hierarchy (via hierarchy/parent metadata on /fields, following your "Supporting multilevel hierarchies in the custom data source API" guide). Manually dragging the top level (e.g. "Invoice Date" -> Year) from the Field List onto Rows works perfectly, including expand/collapse into Quarter/Month/Day.

 

However, we cannot get that same field to appear in Rows/Columns when the report loads from scratch. i.e., pre-selected as a default, the way any non-hierarchy field already can be. Every programmatic method we've tried silently drops the hierarchy-level field with no error.

 

What we've tried (all failed identically):
1. Setting it directly in the initial report.slice.rows (as { uniqueName: "invoiceDateYear", levelName: "Invoice Date" }, matching your documented Slice.rows/SliceHierarchy shape)  via the dataSource prop at first render.
2. Same, but calling pivot.flexmonster.runQuery(slice) imperatively instead of the declarative prop.
3. Same runQuery call plus expands: { expandAllRows: true, expandAllColumns: true } to force auto-drill.
4. Moving the runQuery call to fire only afteplete event (per a note in your releasehistory about setReport() timing before that event).
5. Declaring only the single top ("Year") level vs. all four levels in the slice. No difference.
6. Adding a mapping entry ({ type: 'year/quarter/month/day' }) alongside the CDS fields, per your docs confirming mapping is supported for the Custom Data Source.

 

In every case, calling pivot.flexmonster.getReport() after the pivot fully settles (on querycomplete/reportcomplete) shows the hierarchy field completely absent from rows/columns, and not collapsed, not inactive, just missing even though /fields correctly declares the hierarchy chain and runQuery()/setReport() returns with no error.

 

Evidence:

 

/fields response (correct hierarchy chain):
{ "uniqueName": "invoiceDateYear", "type": "nierarchy": "Invoice Date" },
{ "uniqueName": "invoiceDateQuarter", "type": "string", "caption": "Quarter", "hierarchy": "Invoice Date", "parent":
"invoiceDateYear" },
{ "uniqueName": "invoiceDateMonth", "type": "string", "caption": "Month", "hierarchy": "Invoice Date", "parent": "invoiceDateQuarter" },
{ "uniqueName": "invoiceDateDay", "type": "number", "caption": "Day", "hierarchy": "Invoice Date", "parent": "invoiceDateMonth" }
filters.advanced: true is also set.

 

Attempted initial slice:
{ "rows": [{ "uniqueName": "invoiceDateYear", "levelName": "Invoice Date" }, { "uniqueName": "supplierName" }],
  "columns": [{ "uniqueName": "[Measures]" }]
  "measures": [{ "uniqueName": "totalInvoiceAmount", "aggregation": "sum" }] }

 

getReport() after settle (ground truth, not on
{ "rows": [{ "uniqueName": "supplierName" }], "columns": [{ "uniqueName": "[Measures]" }] }
invoiceDateYear is simply gone.

 

Question: Is there a documented or undocumented way to have a hierarchy-level CDS field placed into Rows/Columns programmatically, so it's pre-selected on fir end user to drag it manually? If this is aknown limitation, is there a workaround, or is it planned to be fixed in a future release?

 

3 answers

Public
Maksym Diachenko Maksym Diachenko Flexmonster 3 days ago

Hello,

Thank you for writing to us and providing the detailed description.

After reviewing the provided server response and config, we found the root cause of this issue. The field names in your row entry are swapped. It should be:

{ "levelName": "invoiceDateYear", "uniqueName": "Invoice Date" }

When you create a hierarchy, the uniqueName in slice should equal the hierarchy name ("Invoice Date"), and levelName is the specific level's uniqueName , which is optionally set when you want to add a particular hierarchy level to the slice. This design lets one slice entry with just the uniqueName address the whole hierarchy as a single unit.

For a deeper level, just change the levelName (for example, "invoiceDateQuarter"), keeping uniqueName as the hierarchy name.

Please check this example of setting a specific hierarchy level with "api" data source: https://jsfiddle.net/flexmonster/pyktbhd2/

We are looking forward to hearing your feedback.

Best regards,
Maksym

Public
Oladipo 3 days ago

Thanks. It is working now

Public
Maksym Diachenko Maksym Diachenko Flexmonster 2 days ago

Hello,

Thank you for your feedback.
We are glad that the issue is resolved.
Feel free to contact us if other questions arise.

Best regards,
Maksym

Please sign in or register to submit your answer