data table to show only category totals

2019-08-10 06:56发布

问题:

I'm trying to implement highcharts and i need a html table for my data source.

This is my view. When I bind my data table to this view, it shows every row instead of categories, which is millions of documents.

I only need category totals to be seen in table.

回答1:

I guess you could use a data table but you might be better off with a repeat control.

Use SSJS Or Java and a Notes View Navigator. That has methods to skip from 1 category to another. So your not looping over each document. As you lop the categories pull out the data. Title and value whatever and add them to a hashmap. Return the hashmap to the repeat control. And use that to get the look similar to what you posted minus the twistie expandability.

If you really do want the twisties, and I hope not, but if you do you can uses a nested repeat control to get that effect.



回答2:

Do not use standard view Data Source, when you need just categories and totals. So get them with view navigator class and feed them into custom structure ([["category", "total"], ["category", "total"]]) and render them with repeat control.

More robust approach would be to use custom data source or managed bean to initialize and hold only category rows.



回答3:

You need a simple JavaScript function that uses a view navigator to pull the category data. While high charts can use a HTML table, you are better off with a json call - less parsing required. Feel free to reuse the function I wrote for exactly that purpose. I used it with d3js but it should be easy to adopt it for high charts.