Adding headers and footers to custom queries
-
- Posts: 7567
- Joined: Sun Apr 24, 2005 12:36 am
- Contact:
Adding headers and footers to custom queries
Let's say you want to represent the content of a custom query as an HTML <table> element. You want the body of the table to be represented by the body of the query template. So the body of the template you will enter into your custom query will look something like this:
<tr>
<td>{Name}</td>
</tr>
But how do you the <table> tag at the beginning and </table> at the end of the HTML? You cannot add it to the template because then it will be repeated for each row.
You can achieve this by adding this simple script to the initialization script of the query:
var oldHandler = config.dataBound;
config.dataBound = function (e)
{
oldHandler (e);
var widgetElem = $("#" + parser.m_widgetInfo.markupId)[0];
widgetElem.innerHTML = "<table>" + widgetElem.innerHTML + "</table>";
}
<tr>
<td>{Name}</td>
</tr>
But how do you the <table> tag at the beginning and </table> at the end of the HTML? You cannot add it to the template because then it will be repeated for each row.
You can achieve this by adding this simple script to the initialization script of the query:
var oldHandler = config.dataBound;
config.dataBound = function (e)
{
oldHandler (e);
var widgetElem = $("#" + parser.m_widgetInfo.markupId)[0];
widgetElem.innerHTML = "<table>" + widgetElem.innerHTML + "</table>";
}
Aware IM Support Team
Re: Adding headers and footers to custom queries
That’s awesome.
I had that question and problem three years ago, with no solution. So I gave up on custom queries for a long time. Thanks
PS. How many more these goodies can you dig up?
I had that question and problem three years ago, with no solution. So I gave up on custom queries for a long time. Thanks
PS. How many more these goodies can you dig up?
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.
Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Aware Programming & Consulting - Tampa FL
Re: Adding headers and footers to custom queries
+1Jaymer wrote:PS. How many more these goodies can you dig up?
From,
Himanshu Jain
AwareIM Consultant (since version 4.0)
OS: Windows 10.0, Mac
DB: MYSQL, MSSQL
Himanshu Jain
AwareIM Consultant (since version 4.0)
OS: Windows 10.0, Mac
DB: MYSQL, MSSQL
-
- Posts: 303
- Joined: Wed Apr 22, 2015 11:44 pm
Re: Adding headers and footers to custom queries
Jaymer wrote:That’s awesome.
I had that question and problem three years ago, with no solution. So I gave up on custom queries for a long time. Thanks
PS. How many more these goodies can you dig up?
Jaymer, have you had any luck with this?
I tried it and just get repeating headers on each line still.
Here is what I have for my HTML:
Code: Select all
<thead>
<tr>
<th>Client Name</th>
<th>Case ID</th>
<th>Case Type</th>
<th>Date Filed</th>
</tr>
</thead>
<tbody>
<tr>
<td>{ClientName}</td>
<td>{CaseID}</td>
<td>{CaseTypeDescription}</td>
<td>{DateFiled}</td>
</tr>
</tbody>
Code: Select all
var oldHandler = config.dataBound;
config.dataBound = function (e)
{
oldHandler (e);
var widgetElem = $("#" + parser.m_widgetInfo.markupId)[0];
widgetElem.innerHTML = "<table class="blueTable"> ++ widgetElem.innerHTML + "</table>";
}
-
- Posts: 620
- Joined: Wed Jun 17, 2015 11:16 pm
- Location: Omaha, Nebraska
- Contact:
Re: Adding headers and footers to custom queries
The header HTML needs be prepended to the widgetElem.innerHTML in the script code, meaning before the ++ in the line below.Jhstephenson wrote:Jaymer wrote:That’s awesome.
I had that question and problem three years ago, with no solution. So I gave up on custom queries for a long time. Thanks
PS. How many more these goodies can you dig up?
Jaymer, have you had any luck with this?
I tried it and just get repeating headers on each line still.
Here is what I have for my HTML:And here is the script I put in:Code: Select all
<thead> <tr> <th>Client Name</th> <th>Case ID</th> <th>Case Type</th> <th>Date Filed</th> </tr> </thead> <tbody> <tr> <td>{ClientName}</td> <td>{CaseID}</td> <td>{CaseTypeDescription}</td> <td>{DateFiled}</td> </tr> </tbody>
Code: Select all
var oldHandler = config.dataBound; config.dataBound = function (e) { oldHandler (e); var widgetElem = $("#" + parser.m_widgetInfo.markupId)[0]; widgetElem.innerHTML = "<table class="blueTable"> ++ widgetElem.innerHTML + "</table>"; }
widgetElem.innerHTML = "<table class="blueTable"> ++ widgetElem.innerHTML + "</table>";
EDIT -
This should have been ..
widgetElem.innerHTML = "<table class='blueTable'>" + widgetElem.innerHTML + "</table>";
Last edited by johntalbott on Thu Nov 29, 2018 5:27 am, edited 1 time in total.
VocalDay Solutions - Agility - Predictability - Quality
We specialize in enabling business through the innovative use of technology.
AwareIM app with beautiful UI/UX - https://screencast-o-matic.com/watch/crfUrrVeB3t
We specialize in enabling business through the innovative use of technology.
AwareIM app with beautiful UI/UX - https://screencast-o-matic.com/watch/crfUrrVeB3t
-
- Posts: 303
- Joined: Wed Apr 22, 2015 11:44 pm
Re: Adding headers and footers to custom queries
johntalbot,
We actually tried that and had the script set to:
But it got data but no headings.
We actually tried that and had the script set to:
Code: Select all
var oldHandler = config.dataBound;
config.dataBound = function (e)
{
oldHandler (e);
var widgetElem = $("#" + parser.m_widgetInfo.markupId)[0];
widgetElem.innerHTML = "<table class="blueTable">
<thead>
<tr>
<th>Client Name</th>
<th>Case ID</th>
<th>Case Type</th>
<th>Date Filed</th>
</tr>
</thead>
++ widgetElem.innerHTML + "</table>";
}
-
- Posts: 620
- Joined: Wed Jun 17, 2015 11:16 pm
- Location: Omaha, Nebraska
- Contact:
Re: Adding headers and footers to custom queries
In your script code if you break the HTML into separate lines you need to wrap each fragment in quotes and concatenate with a +. To make it easier to follow, you might want to set a variable to the header string and then concatenate it to the widgetElem.innerHTML. Something like ...Jhstephenson wrote:johntalbot,
We actually tried that and had the script set to:But it got data but no headings.Code: Select all
var oldHandler = config.dataBound; config.dataBound = function (e) { oldHandler (e); var widgetElem = $("#" + parser.m_widgetInfo.markupId)[0]; widgetElem.innerHTML = "<table class="blueTable"> <thead> <tr> <th>Client Name</th> <th>Case ID</th> <th>Case Type</th> <th>Date Filed</th> </tr> </thead> ++ widgetElem.innerHTML + "</table>"; }
Code: Select all
var headerHTML = "<table class = 'blueTable'> " +
"<thead>" +
"<tr>" +
"<th>Client Name</th>" +
"<th>Case ID</th>" +
"<th>Case Type</th>" +
"<th>Date Filed</th>" +
"</tr>" +
"</thead>"
widgetElem.innerHTML = headerHTML + widgetElem.innerHTML + "</table>"
Also it should be + versus ++ in the concatenation with widgetElem.innerHTML.
VocalDay Solutions - Agility - Predictability - Quality
We specialize in enabling business through the innovative use of technology.
AwareIM app with beautiful UI/UX - https://screencast-o-matic.com/watch/crfUrrVeB3t
We specialize in enabling business through the innovative use of technology.
AwareIM app with beautiful UI/UX - https://screencast-o-matic.com/watch/crfUrrVeB3t
Re: Adding headers and footers to custom queries
Support,
How about adding this functionality back into the config tool instead (to work as it did in previous versions where we had this in the config tool)?
Thanks
How about adding this functionality back into the config tool instead (to work as it did in previous versions where we had this in the config tool)?
Thanks
Henrik (V8 Developer Ed. - Windows)
-
- Posts: 303
- Joined: Wed Apr 22, 2015 11:44 pm
Re: Adding headers and footers to custom queries
Thanks johntalbot that works.