angular - 数据网格强制验证消息未正确显示角度
问题描述
请参考附件视频。
预期结果 - 验证不显示新添加的行
实际结果 - 一旦通过验证触发一行,它也会显示在新添加的行中
这是我添加新行按钮的源代码。
public newRowClicked(){
debugger
// create new empty row
var row:entities.DataRow = new entities.DataRow()
row.fields = JSON.parse(this.template)
row.fields.forEach(f => { f.value=null })
this.dataSet.rows.push(row)
}
HTML
<!-- HEADER -->
<div class="table-row">
<div *ngFor="let header of columnHeaders" [ngStyle]="{'width': (100/(columnCount+1))+'%'}" class="table-cell">
{{header.headerText}}
<span *ngIf="header.isRequired" style="color:red">*</span>
</div>
<div [ngStyle]="{'width': (100/(columnCount+1))+'%'}"></div>
</div>
<!-- FIELDS -->
<div *ngFor="let row of dataSet.rows; index as i">
<app-data-row-view
[field]="field"
[disabled]="disabled"
[formSubmitted]="formButtonClicked"
[isEditMode]="true"
[dataRow]="row"
[columnCount]="columnCount"
[index]="i"
(deleteRowClicked)="deleteRowClicked($event)"></app-data-row-view>
</div>
<!-- CONTROLS -->
<button *ngIf="!disabled" (click)="newRowClicked()" class="btn btn-sm">New Row</button>
<!-- <button style="margin-left:3px" *ngIf="!disabled" (click)="fromCsvClicked()" class="btn btn-secondary btn-sm">From CSV</button> -->
<button class="to-csv-btn" style="margin-left:3px" *ngIf="dataSet.rows.length>0" (click)="viewAsCsvClicked()" class="btn btn-sm">To CSV</button>
<button class="to-json-btn" style="margin-left:3px" *ngIf="dataSet.rows.length>0" (click)="viewAsJsonClicked()" class="btn btn-sm">To JSON</button>
这是在数据网格源代码中创建一行
public addToGrid(){
// creating the row
var row: entities.DataRow = new entities.DataRow()
this.field.dynamicSectionFields.forEach(f => {
row.fields.push(f)
})
// pushing to the list
this.dataSet.rows.push(JSON.parse(JSON.stringify(row)))
console.log(this.dataSet)
window.localStorage.setItem("ds", JSON.stringify(this.dataSet))
}
解决方案
推荐阅读
- yaml - 批准的 PR 评论响应重新部署 GitHub 工作流程
- mysql - MySQL - 选择有数量的最低价格,如果没有数量,选择最低价格
- sql - 如何使用 SSIS Visual Studio 将 .CSV 文件非 Unicode 字符串类型转换为整数
- unix - Unix diff 命令在 UTF-8 文件中用 x96 替换 En-Dash
- r - 我正在尝试使用响应变量的各种转换并拟合相应的这些模型,并获得每个模型的残差图
- javascript - 如何在Javascript中删除字符串中心的单词
- docker - 这个 docker 命令行是做什么的
- git - 不小心将 dev 合并到 master 并推送。已恢复但现在我们无法合并 master 中的旧分支
- sql - AWS Config 字段和建议
- ruby-on-rails-3 - echo 'eval "$(rbenv init -)"' >> ~/.zshrc 不附加 zshrc 文件