Welcome to the nuBuilder Forums!

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

Hide column if form = iframe

Questions related to customising nuBuilder Forte with JavaScript or PHP.
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Has thanked: 3 times
Been thanked: 4 times
Contact:

Hide column if form = iframe

Unread post by kknm »

How to hide a column if the form is currently an iframe on another browse form
kev1n
nuBuilder Team
Posts: 4428
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 475 times
Contact:

Re: Hide column if form = iframe

Unread post by kev1n »

What do you mean by "iframe on another browse form"? Is the browse embedded as iframe in another form (run object with method iFrame) ?
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Has thanked: 3 times
Been thanked: 4 times
Contact:

Re: Hide column if form = iframe

Unread post by kknm »

I have a form (1) with a column = date where the data is entered. The date is taken from another form (2). To the form (2) in edit mode I connect iframe = form (1) where as filter the #form (2)_ date#. Since I already have the date on the main form (2), then in the iframe I do not need it to display it.
data.PNG
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4428
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 475 times
Contact:

Re: Hide column if form = iframe

Unread post by kev1n »

That's how it works for me: Add the JavaScript to the Custom Code of your Browse Form:
cust_code.jpg

Code: Select all

function hideBrowseColumn(column) {
    var cw = parent.$("#" + window.frameElement.id)[0].contentWindow;
    cw.nuFORM.breadcrumbs[cw.nuFORM.breadcrumbs.length - 1].column_widths[column] = 0;
    cw.nuSetBrowserColumns(cw.nuFORM.breadcrumbs[cw.nuFORM.breadcrumbs.length - 1].column_widths)
}

function iniFrame() {
    return window.location !== window.parent.location;
}

if (iniFrame()) {
    $(function () {
        hideBrowseColumn(0); // Hide the first column
    });
}
You do not have the required permissions to view the files attached to this post.
Last edited by kev1n on Tue May 05, 2020 12:26 am, edited 1 time in total.
admin
Site Admin
Posts: 2822
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 29 times

Re: Hide column if form = iframe

Unread post by admin »

kknm,


You can Clone the Form, hide the column, and redirect the new Form to the Original Edit Form.

https://wiki.nubuilder.cloud/ ... edirect_To


Steven
kev1n
nuBuilder Team
Posts: 4428
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 475 times
Contact:

Re: Hide column if form = iframe

Unread post by kev1n »

In kknm's case, cloning is probably not optimal since JS is used in the browse form (redundancy -> maintenance effort)
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Has thanked: 3 times
Been thanked: 4 times
Contact:

Re: Hide column if form = iframe

Unread post by kknm »

I have such iframes on the main form (2) of 7 pieces.
While writing your answer, you changed the function, I was even scared. The changed function works correctly, but I would like it to be possible to do this for all iframes on the main form (2).
kev1n
nuBuilder Team
Posts: 4428
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 475 times
Contact:

Re: Hide column if form = iframe

Unread post by kev1n »

kknm wrote:I have such iframes on the main form (2) of 7 pieces.
While writing your answer, you changed the function, I was even scared.
I just simplified it a little.
but I would like it to be possible to do this for all iframes on the main form (2).
You can add the code to each form or add these two functions to the (Setup -> ) Header. (Log in again to nuBuilder afterwards)

Code: Select all

function hideBrowseColumn(column) {
    var cw = parent.$("#" + window.frameElement.id)[0].contentWindow;
    cw.nuFORM.breadcrumbs[cw.nuFORM.breadcrumbs.length - 1].column_widths[column] = 0;
    cw.nuSetBrowserColumns(cw.nuFORM.breadcrumbs[cw.nuFORM.breadcrumbs.length - 1].column_widths)
}

function iniFrame() {
    return window.location !== window.parent.location;
   // or: 
   // return parent !== window;
}
... and just this code to the iframes:

Code: Select all

if (iniFrame()) {
    $(function () {
        hideBrowseColumn(0); // Hide the first column
    });
}
Last edited by kev1n on Tue May 05, 2020 7:03 am, edited 1 time in total.
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Has thanked: 3 times
Been thanked: 4 times
Contact:

Re: Hide column if form = iframe

Unread post by kknm »

Yes, everything works wonderfully. Finally, I will get rid of a bunch of clones.
I am confused by the warnings in Settings - Title.
header.PNG
You do not have the required permissions to view the files attached to this post.
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Has thanked: 3 times
Been thanked: 4 times
Contact:

Re: Hide column if form = iframe

Unread post by kknm »

There was an unpleasant moment for viewing the iframe - the bottom scroll appeared.
And I would also like to remove the search field and buttons in this row in iframe mode.
Post Reply