Dear visitor, despite the COVID-19 outbreak, our team continues operating at full speed.

Also, here is the form where you can apply for a special discount and we will contact you with possible options. Stay safe and continue achieving your business goals.

Fill the form
Get Free Trial
Get Free Trial

Pivot initialization – show column headers WITHOUT receiving data

Answered
Serban Vasile asked on March 19, 2020

One of the most common issues that our users bring to our attention is the fact that the launch of the web page which contains the pivot also calls the web service and prefills (or at least it tries to prefill) the pivot with data.
That is a big issue because:

  • The data the users are seeing is not necessarily reflecting the filters for the data the users want. We are trying hard to anticipate what they want, but it’s not possible to satisfy all. Also, we are consuming web service time, and may bring data the users discard and that is a bad design no matter what angle you are looking at.
  • In case the default filters on the web service bring no data, the pivot displays an annoying alert (I know you are working on a fix for it), but ALSO the pivot is NOT showing the column headers it was configured for, even without the data below. What we are left is this grid with empty cells, that basically communicates something is not finished, the page errored, and stuff like that.

I think you see where I am going to with this. We need a way to initialize the pivot WITHOUT data, showing the column headers and give it a proper look.
The pivot configuration mentions all these columns we are waiting for…is it really an impossible task what we are asking for?
 
Regards,
Serban

5 answers

Public
Mykhailo Halaida Mykhailo Halaida Flexmonster March 20, 2020

Hi Serban,
 
Thank you for writing to us.
 
In order for us to provide you with the most relevant solution here, could you please give us some more insights on the following points?
 

  1. Does Flexmonster always receive no data at the initial page launch? Or are there situations when some data is instantly passed to the pivot table when the page is opened by the user?
  2. You’ve mentioned that a grid with all cells being empty is not a satisfactory behavior in this situation. What exactly do you think would be a preferable grid view here instead?

 
Just in case this is something close to what you want to achieve, a potential solution in this situation involves defining a dataSource property of the report object as a reference to a CSV file with defined hierarchies but no further data definitions:
 

itemID,price,color,country

 
Please see the attached screenshot to demonstrate the results of this approach.
 
We would be happy to hear your thoughts. Looking forward to hearing from you.
 
Best regards,
Mykhailo

Public
Serban Vasile March 20, 2020

Users do not want any initialization data, period. We don’t want it too, if they would discard it anyway.
Creating a header-only csv is actually harder than bringing some data. Our csv web services actually process json/xml, and apply xslt to results to create csv. No data returned by filters means no output, no headers, nothing. It would be just the same if we processed json, xml. We chose csv because of size. We hate your json solution because you want config metadata as the first member of the json data, not a different path of json metadata. That is VERY difficult to process. Why not jsonpath for metadata, jsonpath for data? It would be so much more intuitive, and we could plug in almost all existing json web services like that. Don’t wait for things to be right at the top of the json tree…allow jsonpath to tell you where to find data and metadata. 
Why can’t you allow a fake refresh, build the header row from the flexmonster json config, where all the columns are mentioned, and format exactly like you would when you would have received at least a row. That is the format we want, the same as it would have data, but with no data.
As always, thanks much for the prompt answers.
Serban

Public
Mykhailo Halaida Mykhailo Halaida Flexmonster March 24, 2020

Hi Serban,
 
Thank you for your swift response.
 
With JSON as your data source, there is another way to predefine the hierarchies and their captions – that is to use the mapping object.
 
This approach is better in your situation than defining a metaobject directly in your data, as in the report it stands independent from the data itself. Moreover, you can use it in combination with an empty data property of the dataSource object to create an empty grid with only hierarchy captions being displayed:
 

dataSource: {    
data: [{}],
mapping: {
"itemID": {
type: "number"
},
"price": {
type: "number"
},
"color": {
type: "string"
},
"country": {
type: "string"
}
},
},

 
Although this is similar to what we’ve suggested with the headers-only CSV in our previous reply, this approach does not require you to load any external data at all – only the headers row is loaded from the report.
 
We’ve prepared a quick JSFiddle example to illustrate this: https://jsfiddle.net/flexmonster/Lw1mozga/
 
For more info on Data Source & Mapping objects feel free to check out the following links:
Data Source: https://www.flexmonster.com/api/data-source-object/
Mapping: https://www.flexmonster.com/api/mapping-object/
 
We would be happy to hear your thoughts on this – please let us know what you think.
 
Best regards,
Mykhailo

Public
Serban Vasile 7 days ago

Ok, data and mapping sound good but:
Can they be represented by functions with params that are SAVED in the config? I mean an equivalent of the url with querystring params? That is the biggest problem with this type of config…I’ve seen examples where data: getData(), but I haven’t seen anything like data: getData({param1: “val1”, param2: “val2”}) that survive the config save as json (as in json produced by Save, loaded with Open Local Report).
The datasource filename: http://blah.com?param1=val1&param2=val2 gets saved into the config json as is, with params, and their values. I need “data” and “mapping” to do the same, allow their being produced dynamically. And again, assuming that will eventually happen, it should also take into account the web service that produces the data/mapping already exists, and doesn’t necessarily have the relevant data/mapping nodes in the root. In other words, I need:

dataSource: {
dataType: "json",
dataUrl: "http://blahdata.com?query1=val1&query2=val2",
dataJsonPath: "$.store.book [*].author",
mappingUrl: "http://blahdata.com?query1=val1&query2=val2",
mappingJsonPath: "$.store.book [*].authorMapping[0]"
}

I think you are following me now. Json paths are pretty much standard, something like here https://www.npmjs.com/package/JSONPath
As always, thank you for your prompt answer.
Serban

Public
Mykhailo Halaida Mykhailo Halaida Flexmonster 18 hours ago

Hi Serban,
 
Our apologies for the slight delay in response here.
 
We just wanted to let you know that our team is currently working on your question and we are evaluating the possible solutions.
 
We will make sure to reach out to you as soon as possible with our response.
 
Thank you for your patience! 
 
Best regards,
Mykhailo

Please login or Register to Submit Answer