Jump to content
  • 0

Can I Use A Aggregate (Total) In Js In The Footer ?


peterhanse

Question

i want use a aggregated total in the footer . is that posible

for example:

<script>

var paard = "voeg uw paard toe!";

var voegtoe = "upgrade uw acount!";

if("cbResultSetTotalsData cbResultSetTotalsDataCellNumberDate" >0)

{

document.write("<p>Link: " + paard.link("http://google.nl") + "</p>")

}

else

{

document.write("<p>Link: " + voegtoe.link("http://caspio") + "</p>")

}

</script>

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Hi peterhanse,

 

Welcome to the Forum! :)

How are you?

 

I think, you can use the following code:

<script>
var column_number = 1;
var myTable = document.getElementsByName("cbTable")[0];
var myRows = myTable.getElementsByTagName("tr");
var lastRow = myRows.length - 1;
var myCells = myRows[lastRow].getElementsByTagName("td");
var myTotal = parseFloat(myCells[column_number].innerHTML);

var paard = "voeg uw paard toe!";
var voegtoe = "upgrade uw acount!";
if(myTotal>0)
{
document.write("<p>Link: " + paard.link("http://google.nl") + "</p>")
}
else
{
document.write("<p>Link: " + voegtoe.link("http://caspio") + "</p>")
}
</script>

Where column_number is the number of the Aggregation.

If you use only one Aggregation, it'll be "1".

 

I'll be grateful, if you tell me if the code works.

Have a nice day!

Link to comment
Share on other sites

  • 0

Hi xiang,

 

your solution below works well if there is a record in the table or view . if it is empty , he gets stuck on "no records found" . what can we do about it .

 

 

<script>

var column_number = 1;

var myTable = document.getElementsByName("cbTable")[0];

var myRows = myTable.getElementsByTagName("tr");

var lastRow = myRows.length - 1;

var myCells = myRows[lastRow].getElementsByTagName("td");

var myTotal = parseFloat(myCells[column_number].innerHTML);

 

var paard = "voeg uw paard toe!";

var voegtoe = "upgrade uw acount!";

if(myTotal>0)

{

document.write("<p>Link: " + paard.link("http://google.nl") + "</p>")

}

else

{

document.write("<p>Link: " + voegtoe.link("http://caspio") + "</p>")

}

</script>

Link to comment
Share on other sites

  • 0

I think the above code might be able to help me.

In my report I have fields for 'year', 'region', 'country', 'product' and 'tonnage'.  The 'region' field is a calculated field.  I wish to show aggregates of my data by region, but also for each year. 

Caspio prevents me grouping data by 'region' because 'region' is a calculated field.  And I can't use 'Totals & Aggregation' either because Caspio only allows me to use 5 of those.  My mix of 'region' and 'year' could end up being many aggregate totals.     

I could be wrong but I think the 5 year-old code from Xiang (above) allows me to add aggregate rows at the bottom of the table... or am I being too optimistic?!   Anyhow, I tried to get his code to work but I think it uses old Caspio commands and all I get is error "Cannot read property 'getElementsByTagName' of undefined". 

Is anyone able to make adjustments to this code to make it more generic?

Alternatively does anyone have any other suggestions on what I can do?

Many thanks

 

 

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...