Page 1 of 4

Hide column if form = iframe

Posted: Mon May 04, 2020 10:56 pm
by kknm
How to hide a column if the form is currently an iframe on another browse form

Re: Hide column if form = iframe

Posted: Mon May 04, 2020 11:11 pm
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) ?

Re: Hide column if form = iframe

Posted: Mon May 04, 2020 11:49 pm
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

Re: Hide column if form = iframe

Posted: Tue May 05, 2020 12:12 am
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
    });
}

Re: Hide column if form = iframe

Posted: Tue May 05, 2020 12:21 am
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

Re: Hide column if form = iframe

Posted: Tue May 05, 2020 12:29 am
by kev1n
In kknm's case, cloning is probably not optimal since JS is used in the browse form (redundancy -> maintenance effort)

Re: Hide column if form = iframe

Posted: Tue May 05, 2020 12:42 am
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).

Re: Hide column if form = iframe

Posted: Tue May 05, 2020 12:47 am
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
    });
}

Re: Hide column if form = iframe

Posted: Tue May 05, 2020 1:18 am
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

Re: Hide column if form = iframe

Posted: Tue May 05, 2020 1:36 am
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.