【问题标题】:Primeng Inputtext: Cancel button functionalityPrimeng Inputtext:取消按钮功能
【发布时间】:2018-11-16 05:57:11
【问题描述】:

我在 Angular 4 上工作,我正在使用 primngg inputtextdataTable。我的页面显示了一个带有键及其值的表,我的要求是当我单击 edit 按钮时,dataTable 中的 value 字段将开始出现在文本字段中。当我cancel 时,它应该撤消所有操作并显示文本字段的原始值,当我单击保存时,我将调用服务来保存它。

我已经完成了Savecancel 我无法弄清楚如何继续前进。谁能指导我如何实现取消按钮功能?

<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"
}

]

【问题讨论】:

  • 可能您需要将数据保存到 temp 变量中以用于取消目的

标签: angular typescript primeng cancel-button


【解决方案1】:

当您subscribing 然后在success store it in a variable(或者您可以根据需要将其存储在两个或多个变量中)并且此变量将存储数据,除非您自愿更改或刷新页面。所以,当你click on cancel assign the data stored in the variable to datatable.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-06-13
    • 2011-05-17
    • 1970-01-01
    • 1970-01-01
    • 2022-10-13
    • 1970-01-01
    • 2020-10-07
    相关资源
    最近更新 更多