Page 1 of 2

save form without full redraw

Posted: Thu Jun 09, 2022 12:01 pm
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.

Re: save form without full redraw

Posted: Thu Jun 09, 2022 1:07 pm
by kev1n
I'm afraid I don't quite understand the question. Could you give more details together with a concrete example?

Re: save form without full redraw

Posted: Thu Jun 09, 2022 2:26 pm
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.

Re: save form without full redraw

Posted: Thu Jun 09, 2022 2:33 pm
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', '', '');
    }

}

Re: save form without full redraw

Posted: Thu Jun 09, 2022 2:38 pm
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

Re: save form without full redraw

Posted: Thu Jun 09, 2022 2:46 pm
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?

Re: save form without full redraw

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

Code: Select all

var openPopup = false;

Re: save form without full redraw

Posted: Thu Jun 09, 2022 2:58 pm
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.

Re: save form without full redraw

Posted: Thu Jun 09, 2022 3:57 pm
by kev1n
Can you post your current code?

Re: save form without full redraw

Posted: Thu Jun 09, 2022 5:09 pm
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?