Welcome to the nuBuilder Forums!

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

save form without full redraw

Questions related to using nuBuilder Forte.
selector
Posts: 41
Joined: Tue Feb 22, 2022 1:55 pm
Has thanked: 9 times

save form without full redraw

Unread post by selector »

I apologize for such a simple question. nuSaveAction() leads to the interruption of the procedure from which it is called and the redrawing of the entire form. Is there a regular way to save data with the receipt of data-nu-primary-key without stopping the procedure. As an example, before adding rows to the table, you need to know the primary key of the parent form.
kev1n
nuBuilder Team
Posts: 4294
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: save form without full redraw

Unread post by kev1n »

I'm afraid I don't quite understand the question. Could you give more details together with a concrete example?
selector
Posts: 41
Joined: Tue Feb 22, 2022 1:55 pm
Has thanked: 9 times

Re: save form without full redraw

Unread post by selector »

Code: Select all

function selectSotr(){
    if (nuIsNewRecord()) {
        nuSaveAction();
    }
    
    let arrRows = nuSubformObject('sf_yavka').rows;
    let arrChecked = [];
    for (let index = 0; index < arrRows.length; ++index) {
        arrChecked.push(arrRows[index][1]);
    }
    localStorage.setItem("arrChecked", JSON.stringify(arrChecked));
    nuPopup('627e8e6691182e4', '', '');
}
I need to save the original document and then open a new form. In the example above, the popup form does not open the first time after inserting new record- only when clicked again.
kev1n
nuBuilder Team
Posts: 4294
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: save form without full redraw

Unread post by kev1n »

Would something like this work?

Code: Select all

var openPopup = false;

function selectSotr() {
    if (nuIsNewRecord()) {
        openPopup = true;
        nuSaveAction();
    } else {
        openPopup = false;
    }
}

function nuAfterSave() {

    if (openPopup === true) {
        let arrRows = nuSubformObject('sf_yavka').rows;
        let arrChecked = [];
        for (let index = 0; index < arrRows.length; ++index) {
            arrChecked.push(arrRows[index][1]);
        }
        localStorage.setItem("arrChecked", JSON.stringify(arrChecked));
        nuPopup('627e8e6691182e4', '', '');
    }

}
selector
Posts: 41
Joined: Tue Feb 22, 2022 1:55 pm
Has thanked: 9 times

Re: save form without full redraw

Unread post by selector »

Yes. It was easy ) Popup should open anyway. Regardless of whether there is a new entry or not. But in this case, I can simply add a function call to the else block. Thanks
selector
Posts: 41
Joined: Tue Feb 22, 2022 1:55 pm
Has thanked: 9 times

Re: save form without full redraw

Unread post by selector »

Code: Select all

function fillSotrPopup(){
    let arrRows = nuSubformObject('sf_yavka').rows;
    let arrChecked = [];
    for (let index = 0; index < arrRows.length; ++index) {
        arrChecked.push(arrRows[index][1]);
    }
    localStorage.setItem("arrChecked", JSON.stringify(arrChecked));
    nuPopup('627e8e6691182e4', '', '');
}

function nuAfterSave(){
    if (openPopup === true) {
        fillSotrPopup();
    }
}

function selectSotr(){
  if (nuIsNewRecord()) {
        openPopup = true;
        nuSaveAction();
    } else {
        openPopup = false;
        fillSotrPopup();
    }
}
Still, for some reason it does not work.
in nuAfterSave openPopup variable = false in debugger )
Maybe I should use nuSetProperty?
kev1n
nuBuilder Team
Posts: 4294
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: save form without full redraw

Unread post by kev1n »

Try omitting

Code: Select all

var openPopup = false;
selector
Posts: 41
Joined: Tue Feb 22, 2022 1:55 pm
Has thanked: 9 times

Re: save form without full redraw

Unread post by selector »

kev1n wrote: Thu Jun 09, 2022 2:52 pm Try omitting

Code: Select all

var openPopup = false;
Yes already did it ) Thank you.
PS: But I used nuSetProperty as a storage. You cannot omit the variable declaration. Or I did something wrong.
kev1n
nuBuilder Team
Posts: 4294
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: save form without full redraw

Unread post by kev1n »

Can you post your current code?
selector
Posts: 41
Joined: Tue Feb 22, 2022 1:55 pm
Has thanked: 9 times

Re: save form without full redraw

Unread post by selector »

Code: Select all

function fillSotrPopup(){
    let arrRows = nuSubformObject('sf_yavka').rows;
    let arrChecked = [];
    for (let index = 0; index < arrRows.length; ++index) {
        arrChecked.push(arrRows[index][1]);
    }
    localStorage.setItem("arrChecked", JSON.stringify(arrChecked));
    nuPopup('627e8e6691182e4', '', '');
}

function selectSotr(){
  if (nuIsNewRecord()) {
        nuSetProperty("openPopup", "1", true);
        nuSaveAction();
    } else {
        nuSetProperty("openPopup", "0", true);
        fillSotrPopup();
    }
}


function nuAfterSave(){
    if (nuGetProperty("openPopup") === "1") {
        nuSetProperty("openPopup", "0", true);
        fillSotrPopup();
    }
}
I realized that I should have just written var openPopup; Without initialization. But if the action of the var directive ever changes, the code will break. And this code, although it looks a little more cumbersome, but it will work. Or am I not noticing some kind of problem?
Post Reply