Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Cannot print table Topic is solved

Questions related to using nuBuilder Forte.
nadir
Posts: 39
Joined: Mon Apr 21, 2025 7:03 am
Has thanked: 4 times
Been thanked: 4 times

Re: Cannot print table

Unread post by nadir »

I added the JavaScript code to the custom code section of the parent form but it gave the following error:
screenshot-1.png
Also see the following screenshot:
screenshot-2.png
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Cannot print table

Unread post by kev1n »

At the time the main form is loaded, the iframe does not yet exist.
Therefore, it cannot be accessed at that point.
Solution: Either add a delay, or even better, set the Hash Cookie directly within the iframe.
nadir
Posts: 39
Joined: Mon Apr 21, 2025 7:03 am
Has thanked: 4 times
Been thanked: 4 times

Re: Cannot print table

Unread post by nadir »

How do I directly set the Hash Cookie within the iframe ?
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Cannot print table

Unread post by kev1n »

Does the iframe retrieve the date from an object on the main form? And if no date is entered, what data should be displayed—for example, a default date like today, yesterday, etc.?
nadir
Posts: 39
Joined: Mon Apr 21, 2025 7:03 am
Has thanked: 4 times
Been thanked: 4 times

Re: Cannot print table

Unread post by nadir »

The iframe retrieves date from a date object on the main form. If no date is entered, the date object is set to todays date using JavaScript
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Cannot print table

Unread post by kev1n »

In the iframe, check whether the date_filter hash cookie is set. If it isn't, set it to the current date.

Place the following code in the iframe > Custom Code > Browse field:

Code: Select all

if (!nuGetProperty('date_filter')) {
  nuSetProperty('date_filter', nuCurrentDate());
}
nadir
Posts: 39
Joined: Mon Apr 21, 2025 7:03 am
Has thanked: 4 times
Been thanked: 4 times

Re: Cannot print table

Unread post by nadir »

I set the code you sent, but it did not help. The print view still shows no rows
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Cannot print table

Unread post by kev1n »

There are too many factors that could make it not work, and it's time-consuming to keep guessing without seeing the setup, code, etc.
Would it be possible for you to either export your database (with any confidential data removed) or share the form using the cloner tool, along with the associated tables? That way, I can provide more accurate help without making assumptions.
nadir
Posts: 39
Joined: Mon Apr 21, 2025 7:03 am
Has thanked: 4 times
Been thanked: 4 times

Re: Cannot print table

Unread post by nadir »

Please see attached SQL database file. The form with issues is under User Home -> Reporting -> Daily Report
ams.zip
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Cannot print table

Unread post by kev1n »

In the form's Custom Code, the default date is explicitly set:
$("#date_filter").val("2021-11-01");

However, in the iframe, a different default date (today's date) is set dynamically:

Code: Select all

if (!nuGetProperty('date_filter')) {
    nuSetProperty('date_filter', nuCurrentDate());
}
Since the iframe uses the current date (which may not have corresponding data), the table appears empty, and the Print page shows up blank.

Additionally, when the date is changed, the new value must be saved to the Hash Cookie so that the iframe reflects the update correctly:

Code: Select all

var f = $("#daily_report_iframe")[0].contentWindow;
f.nuSetProperty("date_filter", this.value); // add this line
f.nuGetBreadcrumb();
Post Reply