Primeng Inputtext: Cancel button functionality












0















I work on Angular 4 and I am using primgng inputtext and dataTable. My page shows a table with key and its value and my requirement is when I click on the edit button, the value field in the dataTable will start appearing in the text field. When I cancel it should undo all the actions and show the original value of the text field and when I click on save I will make a service call to save it.



I am done with Save but cancel I am not able to figure out how to move ahead. Can any one please guide me how to implement cancel button functionality?



<button>Edit</button>
<button>Cancel</button>
<button>Save</button>

<p-dataTable [value]="fileInfo" [sortField]="sortF" [sortOrder]="sortO" (onSort)="changeSort($event)">
<p-column field="key" header="Vin" [sortable]="true"></p-column>
<p-column field="value" header="Year" [sortable]="true">
<ng-template let-col let-item="rowData">
<input id="float-input" type="text" size="30" pInputText value-"{{item.value}}">
</ng-template>
</p-column>
<p-footer>
<button type="button" label="Sort by Year" (click)="changeSort($event)" pButton></button>
</p-footer>
</p-dataTable>

this.fileInfo = [{
key: "Name",
value: "ABC"
},
{
key: "Age",
value: "45"
},
{
key: "Place",
value: "NY"
},
{
key: "Book",
value: "A1"
},
{
key: "Contact",
value: "123456"
}

]









share|improve this question























  • May be you need to save data into temp variable for cancel purpose

    – Pardeep Jain
    Nov 16 '18 at 6:04
















0















I work on Angular 4 and I am using primgng inputtext and dataTable. My page shows a table with key and its value and my requirement is when I click on the edit button, the value field in the dataTable will start appearing in the text field. When I cancel it should undo all the actions and show the original value of the text field and when I click on save I will make a service call to save it.



I am done with Save but cancel I am not able to figure out how to move ahead. Can any one please guide me how to implement cancel button functionality?



<button>Edit</button>
<button>Cancel</button>
<button>Save</button>

<p-dataTable [value]="fileInfo" [sortField]="sortF" [sortOrder]="sortO" (onSort)="changeSort($event)">
<p-column field="key" header="Vin" [sortable]="true"></p-column>
<p-column field="value" header="Year" [sortable]="true">
<ng-template let-col let-item="rowData">
<input id="float-input" type="text" size="30" pInputText value-"{{item.value}}">
</ng-template>
</p-column>
<p-footer>
<button type="button" label="Sort by Year" (click)="changeSort($event)" pButton></button>
</p-footer>
</p-dataTable>

this.fileInfo = [{
key: "Name",
value: "ABC"
},
{
key: "Age",
value: "45"
},
{
key: "Place",
value: "NY"
},
{
key: "Book",
value: "A1"
},
{
key: "Contact",
value: "123456"
}

]









share|improve this question























  • May be you need to save data into temp variable for cancel purpose

    – Pardeep Jain
    Nov 16 '18 at 6:04














0












0








0








I work on Angular 4 and I am using primgng inputtext and dataTable. My page shows a table with key and its value and my requirement is when I click on the edit button, the value field in the dataTable will start appearing in the text field. When I cancel it should undo all the actions and show the original value of the text field and when I click on save I will make a service call to save it.



I am done with Save but cancel I am not able to figure out how to move ahead. Can any one please guide me how to implement cancel button functionality?



<button>Edit</button>
<button>Cancel</button>
<button>Save</button>

<p-dataTable [value]="fileInfo" [sortField]="sortF" [sortOrder]="sortO" (onSort)="changeSort($event)">
<p-column field="key" header="Vin" [sortable]="true"></p-column>
<p-column field="value" header="Year" [sortable]="true">
<ng-template let-col let-item="rowData">
<input id="float-input" type="text" size="30" pInputText value-"{{item.value}}">
</ng-template>
</p-column>
<p-footer>
<button type="button" label="Sort by Year" (click)="changeSort($event)" pButton></button>
</p-footer>
</p-dataTable>

this.fileInfo = [{
key: "Name",
value: "ABC"
},
{
key: "Age",
value: "45"
},
{
key: "Place",
value: "NY"
},
{
key: "Book",
value: "A1"
},
{
key: "Contact",
value: "123456"
}

]









share|improve this question














I work on Angular 4 and I am using primgng inputtext and dataTable. My page shows a table with key and its value and my requirement is when I click on the edit button, the value field in the dataTable will start appearing in the text field. When I cancel it should undo all the actions and show the original value of the text field and when I click on save I will make a service call to save it.



I am done with Save but cancel I am not able to figure out how to move ahead. Can any one please guide me how to implement cancel button functionality?



<button>Edit</button>
<button>Cancel</button>
<button>Save</button>

<p-dataTable [value]="fileInfo" [sortField]="sortF" [sortOrder]="sortO" (onSort)="changeSort($event)">
<p-column field="key" header="Vin" [sortable]="true"></p-column>
<p-column field="value" header="Year" [sortable]="true">
<ng-template let-col let-item="rowData">
<input id="float-input" type="text" size="30" pInputText value-"{{item.value}}">
</ng-template>
</p-column>
<p-footer>
<button type="button" label="Sort by Year" (click)="changeSort($event)" pButton></button>
</p-footer>
</p-dataTable>

this.fileInfo = [{
key: "Name",
value: "ABC"
},
{
key: "Age",
value: "45"
},
{
key: "Place",
value: "NY"
},
{
key: "Book",
value: "A1"
},
{
key: "Contact",
value: "123456"
}

]






angular typescript primeng cancel-button






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 16 '18 at 5:57









AnnaAnna

5233828




5233828













  • May be you need to save data into temp variable for cancel purpose

    – Pardeep Jain
    Nov 16 '18 at 6:04



















  • May be you need to save data into temp variable for cancel purpose

    – Pardeep Jain
    Nov 16 '18 at 6:04

















May be you need to save data into temp variable for cancel purpose

– Pardeep Jain
Nov 16 '18 at 6:04





May be you need to save data into temp variable for cancel purpose

– Pardeep Jain
Nov 16 '18 at 6:04












1 Answer
1






active

oldest

votes


















0














When you subscribing then on success store it in a variable(or you can store it in two or more variables based on requirement) and this variable will store the data unless it is changed voluntarily by you or page is refeshed. So, when you click on cancel assign the data stored in the variable to datatable.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53332216%2fprimeng-inputtext-cancel-button-functionality%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    When you subscribing then on success store it in a variable(or you can store it in two or more variables based on requirement) and this variable will store the data unless it is changed voluntarily by you or page is refeshed. So, when you click on cancel assign the data stored in the variable to datatable.






    share|improve this answer




























      0














      When you subscribing then on success store it in a variable(or you can store it in two or more variables based on requirement) and this variable will store the data unless it is changed voluntarily by you or page is refeshed. So, when you click on cancel assign the data stored in the variable to datatable.






      share|improve this answer


























        0












        0








        0







        When you subscribing then on success store it in a variable(or you can store it in two or more variables based on requirement) and this variable will store the data unless it is changed voluntarily by you or page is refeshed. So, when you click on cancel assign the data stored in the variable to datatable.






        share|improve this answer













        When you subscribing then on success store it in a variable(or you can store it in two or more variables based on requirement) and this variable will store the data unless it is changed voluntarily by you or page is refeshed. So, when you click on cancel assign the data stored in the variable to datatable.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 16 '18 at 6:18









        MahiMahi

        768421




        768421
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53332216%2fprimeng-inputtext-cancel-button-functionality%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            List item for chat from Array inside array React Native

            Thiostrepton

            Caerphilly