Hello
@Buddhi Guptaattached pls find an extension as proposed.
Also save a commit here
https://github.com/raro42/cognos/blob/master/toggleGroupedCrosstab_Extension/It uses the "common" view. So is always loaded.
It also loads the common.css where you can globally declare and overwrite css rules.
Upload the extension to your portal, wait minute or two to sync in the filesystem.
Reload the portal Shift+F5, observe that AmvaraCommonJs.js is loaded in Network TAB of Chrome (Ctrl-Shift-I).
There are two functions "t" + "tx" inside that archive.
There is little documentation inside the archive. So
it is not lost, when as this post gets older.
Use the functions t() + tx() in your report in onclick action of element:
window.top.amvara.t('myClassname')
or
window.top.amvara.tx('mySelector').
myClassname should not have a starting "." Using t function
you must insert empty boxes into the cells to be grouped and give them the classname.
It must be a single classname on that element. Not two or more! The parent element, which
is the TD with the number, is then selected for toggeling.
mySelector should be a valid css selector selecting the fact cells to group.
E.g "td[style='background-color: #cecece']"
So, adding and HTML-item with
<span onclick=window.top.amvara.t('cls1')>Toggle Column Group 1</span>
should do the work.
We might think about finetuning HTML-item, adding layout elements, that also provides layouts with "+" and "-", to click on, as seen in your first screenshot.
Ideas are welcome. As archive is on github ... feel yourself invited to contribute.
Stay healthy. Thank you and Paul for this thread. Looking forward to your comments.
Ralf
------------------------------
Ralf Roeber
Managing Partner
Amvara Consulting
------------------------------
Original Message:
Sent: Thu June 18, 2020 11:54 AM
From: Buddhi Gupta
Subject: List Column grouping Custom Control
Hello @Ralf Roeber, can we add JS using extension ot have to add as Custom Control to work with any report? Thank you again for your help!
------------------------------
Buddhi Gupta
Original Message:
Sent: Thu June 18, 2020 11:13 AM
From: Ralf Roeber
Subject: List Column grouping Custom Control
Hello @Paul Mendelson,
had a look at the ctx values. These actually make up the coordinates of each cell.
So, from there taking the parent and removing or adding 1 to the colspan attribute works smooth.
I did a proof-of-concept for a nested crosstab with one level of nesting.
The report has years on top and six value columns which we want to group in 3+3+2
HTML-item to insert before crosstab:
<img src="hal/images/blank.gif" onload='
t = function(myClass) {
var sq = String.fromCharCode(39);
var iframe = window.top.$("#rsIFrameManager_1").contents();
ctxArray = iframe.find("div[class=" + sq + myClass+ sq + "]").parent();
window.top.$.each(ctxArray, function(i, n) {
var ctx = n.getAttribute("ctx");
/* Toggle this ctx */
console.log("Toggeling:",ctx);
var elm = iframe.find("td[ctx$=" + sq + ctx + sq + "]");
elm.toggle();
/* Check for parent colspans */
parentCtxs = ctx.split(":");
console.log("Parent Ctxs:", parentCtxs);
var parentCtx = parentCtxs.pop();
var selector = "td[ctx=" + sq + parentCtx + sq + "]";
var colspan = iframe.find(selector);
/* remove or add colspan depending of toggle situation */
var colspanAdder = ( elm.is(":visible") ) ? 1 : -1;
var colspanNewvalue = colspan.attr("colspan")*1;
colspanNewvalue = colspanNewvalue + colspanAdder;
colspan.attr("colspan", colspanNewvalue );
});
};' />
<span onclick="t('cls1')">Toggle 1</span> - <span onclick="t('cls2')">Toggle 2</span> - <span onclick="t('cls3')">Toggle 3</span>
As this is just a proof-of-concept, it only works for one level nesting.
For further nesting one would have to recursively call a colspan calculation.
Might do this in the future, if there is a demand.
Attached find the reportSpecs.
Thanks for pointing out the nesting problem. It is an interesting request. Would love to read comments on the proposed solution.
Stay healthy.
------------------------------
Ralf Roeber
Managing Partner
Amvara Consulting
Original Message:
Sent: Wed June 17, 2020 04:40 AM
From: Paul Mendelson
Subject: List Column grouping Custom Control
I have an idea to get vertical expand/collapse working, but it's not going to be as smooth as the row expand/collapse. The user will have to define a number of things in HTML items, and I also need to consider how to handle overlapping expand/collapse ranges.
------------------------------
Paul Mendelson
Original Message:
Sent: Tue June 16, 2020 03:19 PM
From: Buddhi Gupta
Subject: List Column grouping Custom Control
Thanks Albert! With that option, probably we can use Sample Custom control available to hide all columns together. Only thing is we need to fix the width of all columns to align with Header Table.
I am looking something similar to Expand and Collapse Custom Control @Paul Mendelson created for rows but now for columns.
@Ralf Roeber, are you talking about putting it as Custom Control or using extension to refer to files like you shared for CSS? Will extension approach to refer JS work in interactive mode? Thank you again for your help!
------------------------------
Buddhi Gupta
Original Message:
Sent: Tue June 16, 2020 12:05 PM
From: Albert Valdez
Subject: List Column grouping Custom Control
One technique that I use frequently to condense lists is by consolidating multiple data items into a single column using a nested Table inside of a single column, for instance the customer contact info/address data can be placed in a multi-row Table with 2 columns, one with the label, the other with the values, and dropped into a single column by using the Unlock Cells feature. It's not as attractive as the Javascript solution, but much easier to maintain.
Hope that helps!
------------------------------
Albert Valdez
albert@intelalytics.com
Original Message:
Sent: Mon June 15, 2020 01:16 PM
From: Buddhi Gupta
Subject: List Column grouping Custom Control
Hi All
Is there any custom control to group columns in a list so that we can shorten list with large number of columns?
Thanks for any inputs!
------------------------------
Buddhi Gupta
------------------------------
#CognosAnalyticswithWatson