Jump to content
  • 0

Setting the header/label for an HTML block field.


perchance

Question

I have a tabular result set that I'd like format the alignment for. Using advice here on the forums, I've substituted

[@field:NumericField]%

For the generic field.

That works great for the right align, but then I lose the \"label\" that sets the column's header row. Is there any way to keep that in AND adjustment the alignment?

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

I agree, it would be very useful to be able to define the header of a html block.

To control the alignment of each column, you can use script like:

var stl='none';

var tbl = document.getElementsByTagName('table')[5]; // 5 for the number of tables before you datapage

var rows = tbl.getElementsByTagName('tr');

for (var row=1; row

var cels = rows[row].getElementsByTagName('td');

cels[0].style.textAlign='left';

cels[2].style.textAlign='center';

cels[4].style.textAlign='right';

cels[6].style.display=stl; // if you want to hide the data of a column

}

I have a tabular result set that I'd like format the alignment for. Using advice here on the forums, I've substituted

[@field:NumericField]%

For the generic field.

That works great for the right align, but then I lose the "label" that sets the column's header row. Is there any way to keep that in AND adjustment the alignment?

Link to comment
Share on other sites

  • 0

If you were able to customize the results table with Java Script, why don't you simply add a header label to that spedific column within the JS? You could simply add the following to the already existing code:

var colheader = rows[0].getElementsByTagName(\"td\");

colheader[10].innerHTML=\"HEADER\";

Note: It should be outside of the \"for\" loop.

Link to comment
Share on other sites

  • 0

Very good idea and simple to put in place.

Thanks

If you were able to customize the results table with Java Script, why don't you simply add a header label to that spedific column within the JS? You could simply add the following to the already existing code:

var colheader = rows[0].getElementsByTagName("td");

colheader[10].innerHTML="HEADER";

Note: It should be outside of the "for" loop.

Link to comment
Share on other sites

  • 0

Can someone please help! I've tried using the suggestions listed here but they aren't working. I must need to change something but don't have any idea what to change. To set a label in the header I tried both options offered, both left the label field blank.

I tried

var colheader = rows[0].getElementsByTagName(\"td\");

colheader[10].innerHTML=\"HEADER\";

What do I change the <\td\> to so it will work? This code is in a HTML Block so there isn't a caspio fieldname associated with it.

To hide a column I tried the following - I set the table number to both 0 and 1 neither worked(It's the only table deployed on the page. Do I need to replace 'tr' with something? (I have this in the header block)

var stl='none';

var tbl = document.getElementsByTagName('table')[5]; // 5 for the number of tables before you datapage

var rows = tbl.getElementsByTagName('tr');

for (var row=1; row

var cels = rows[row].getElementsByTagName('td');

cels[9].style.display=stl; // if you want to hide the data of a column

}

thanks for any help!!!

Link to comment
Share on other sites

  • 0

To assign a label to a column, make sure the code is as below:

<script>
var colheader = rows[0].getElementsByTagName("td");
colheader[10].innerHTML="<font size=1><b>HEADER<b></font>";
</script>

You need to replace number 10 with the corresponding column number.

To hide a column in results page put that code inside the footer.

Best,

Bahar M.

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