简体   繁体   English

通过使用独立不工作分隔每一行

[英]separate each row by using standalone not working

I have a simple grid just for users to type comments, the grid will have multiple rows, however, when user type in row one, all the row are typed together.我有一个简单的网格供用户输入评论,网格将有多行,但是,当用户在第一行输入时,所有行都一起输入。 I added ngmodeloptions standalone is true.我添加了 ngmodeloptions 独立是真的。 However, ngModelOptions seems not working at all html file但是,ngModelOptions 似乎根本不起作用 html 文件

<kendo-grid [pageable]="true" [kendoGridBinding]="commentsGrid">
   <kendo-grid-column field="comment" title="comment" width="80">
     <ng-template kendoGridCellTemplate let-dataItem = "dataItem" let-isNew="isNew" let-column = "column" let-rowIndex="rowIndex" let-formGroup="formGroup">
       <input type="text" name="comments" [(ngModel)]="dataItem.comments" [ngModelOptions]="{standalone: true}" >
     </ng-template>
   </kendo-grid-column>
</kendo-grid]

ts file ts文件

commentsGrid = [{
 "comment": null
},
{
 "comment": null
}]

so when I type on row two, both row one and row two start typing together, is there anyway can type each row separately?所以当我在第二行输入时,第一行和第二行都开始一起输入,是否可以单独输入每一行?

Because all input tag of you has same name attribute.因为您的所有输入标签都具有相同的名称属性。 You can generate the name of input tag with your rowIndex variable to each input tag has 1 unique name like:您可以使用 rowIndex 变量生成输入标签的名称,每个输入标签都有 1 个唯一名称,例如:

name="comments_{{ rowIndex  }}"

Hope this help!希望这有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM