Jump to content
  • 0

Link in Group by row


NickO

Question

I am sure this is not unique but I cannot find anything on it for some reason. I have grouped data (i.e. State expands out to a list of cities). I want to put a link to additional data that is at the State level. Is there any way to do this? I don't want the link on every City row because that implies the data is for the city and not the state.

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Hello @NickO

You need to use additional JS code to convert your Grouping labels to links.
You need to insert this code into the Footer of the result set. Also, you need to disable HTML editor of the Footer in the Advanced options.
Here is the code:

<script>
function appendLink(elems) {
  let detailsLink = "https://account_id.caspio.com/dp/datapage_app_key?param=";

  for(let elem of elems) {
    let link = document.createElement('a');
    link.href = detailsLink + elem.childNodes[0].innerText;
    link.innerText = elem.childNodes[0].innerText;
    link.style.cssText = "color: white; font-size: 12px; font-family: Arial, sans-serif; font-weight: normal;";

    elem.childNodes[0].innerText = '';
    elem.childNodes[0].appendChild(link);
  }
};

document.addEventListener('DataPageReady', appendLink(document.querySelectorAll('tr[data-cb-name^="group"]')));
</script>

The idea is to pass the value of the label as the parameter and get the information related to it. In your case, you may pass the name of state.
To do that, you need to change this part of code:

let detailsLink = "https://account_id.caspio.com/dp/datapage_app_key?param=";

//  https://account_id.caspio.com/dp/datapage_app_key - web link where you have your details DataPage
//  param - the name of the parameter you use in search criteria


To get familiar with passing parameters please check this page - https://howto.caspio.com/parameters/parameters-as-query-string-values/

Let me know if you have any questions.

Link to comment
Share on other sites

  • 0

Thank you very much for the reply @Andrew  This is very close to what I want to do. I am only good enough with js to be dangerous. My actual solution is Solutions and Details (in screenshot below). The City/State was just an easy visualization. I was able to do some minor tweaking (mainly formatting, link construct, etc. and nothing functional) to get it closer to what I need but still having trouble with two bits. I'm hoping somebody can help on this part.

First, for some reason I am getting the same ID for every parameter...so in my case specifically it is SolutionID=[@field:aNEW_Solution_SolutionID]. When I add a link in an HTML Block, it works great. But here for some reason, it always populates the same SolutionID (first in the database) instead of dynamically assigning it based on the row of the report. So, for illustration, in the screenshot below QA-QC should have an ID of 2000 and Reports of 1000. Instead, both links have an ID of 1000.

Second, the heading I want to replace with a link is actually at the second level. Below is a snip to illustrate. Instead of the blue linked heading, I want to change those in the red boxes to links. Is this possible?

image.png.a8a63ad46d2f163e506e29534cffe2a2.png

 

 

Link to comment
Share on other sites

  • 0

Hello @NickO

To make links from the labels of the second level of grouping, please use this code:

<script>
function appendLink(elems) {
  let detailsLink = "https://account_id.caspio.com/dp/datapage_app_key?param=";

  for(let elem of elems) {
    let link = document.createElement('a');
    link.href = detailsLink + '?param=' + elem.innerText;
    link.innerText = elem.innerText;
    link.style.cssText = "color: white; font-size: 12px; font-family: Arial, sans-serif; font-weight: normal;";

    elem.innerText = '';
    elem.appendChild(link);
  }
};

document.addEventListener('DataPageReady', appendLink(document.querySelectorAll('td[data-cb-name="groupLabelCell2"]')));
</script>

As I mentioned before, insert this code into the Footer of the result set. Do not forget to disable HTML editor of the Footer in the Advanced options.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...