Issue Description
This issue happens when I pivot a dataset by 1 or more rows and 0 columns over 1 or more aggregated measures. When the dataset column I choose as a pivot row contains NULL data, the aggregated values does not display.
Version Details
Attached Files Details
Refer to the reference.zip file for reference materials on the issue.
Data Server API - non-working scenario vs working scenario
non-working scenario: this scenario pivots the dataset "filename" column, where the column is having some null data
non-working api: /select
non-working api payload: {"type":"select","index":"1933903","query":{"aggs":{"by":{"rows":[{"uniqueName":"operation"},{"uniqueName":"filename"}]},"values":[{"func":"count","field":{"uniqueName":"command"}},{"func":"count","field":{"uniqueName":"who"}}]},"filter":[{"field":{"uniqueName":"operation"},"include":[{"member":"execution"}]}]},"querytype":"expand","page":0}
non-working api response: {"fields":null,"hits":null,"aggs":[{"keys":{},"values":{"command":{"count":3},"who":{"count":3}}},{"keys":{"operation":"execution"},"values":{"command":{"count":3},"who":{"count":3}}},{"keys":{"filename":null},"values":{"command":{"count":3},"who":{"count":3}}},{"keys":{"filename":null,"operation":"execution"},"values":{"command":{"count":3},"who":{"count":3}}}],"pageTotal":1,"page":0,"nextPageToken":null}
working scenario: this scenario pivots the dataset "filename1" column, where the column data are all non-null
working api: /select
working api payload: {"type":"select","index":"1933908","query":{"aggs":{"by":{"rows":[{"uniqueName":"operation"},{"uniqueName":"filename1"}]},"values":[{"func":"count","field":{"uniqueName":"command"}},{"func":"count","field":{"uniqueName":"who"}}]},"filter":[{"field":{"uniqueName":"operation"},"include":[{"member":"execution"}]}]},"querytype":"expand","page":0}
working api response: {"fields":null,"hits":null,"aggs":[{"keys":{},"values":{"command":{"count":3},"who":{"count":3}}},{"keys":{"operation":"execution"},"values":{"command":{"count":3},"who":{"count":3}}},{"keys":{"filename1":"empty"},"values":{"command":{"count":3},"who":{"count":3}}},{"keys":{"operation":"execution","filename1":"empty"},"values":{"command":{"count":3},"who":{"count":3}}}],"pageTotal":1,"page":0,"nextPageToken":null}
Hello, Jun Jie,
Thank you for reaching out to us.
We reviewed the provided screenshots and the /select responses from both scenarios. The difference is how the empty member is represented in the response keys.
In the custom data source API, null values are not recognized as a member key in the /select response. By default, Flexmonster treats null, undefined, and an empty string as one empty value, and the empty string "" is the expected token for that value in the /select response. The non-working response returns "filename": null in the keys, so the component can't match these aggregations to the empty member, and the values are not displayed.
To fix this, return an empty string instead of null for empty members in the /select response. This is semantically close to what you are trying to achieve and should display the expanded rows correctly.
Alternatively, you can enable the distinguishNullUndefinedEmpty option. This should allow null members to be displayed as they are without any changes on the server side. Note that it disables the grouping described above, so empty strings and null values from your data will become two separate members.
Please let us know if one of the suggested approaches worked for you.
Best regards,
Maksym
Hi Maksym,
I have mapped the null values as empty string for the members values in "keys" field and the behavior is working as expected.
Thanks.
Hello, Jun Jie,
Thank you for your feedback.
We are glad that replacing null with an empty string in custom API responses is a viable solution for you.
Feel free to contact us if any other questions arise.
Best regards,
Maksym