如何根据某些条件在剑道网格中禁用下拉列表。
在我的代码中,当状态为“拒绝”时,应启用下拉列表,否则应禁用。但是,当我将 DDLdisabled 设置为true时,它将启用网格中的所有下拉列表。
仅当我选中“拒绝”或“完成”单选按钮时,才需要启用或禁用相应的行下拉列表。 怎么做?
请帮助我。
HTML代码:
<kendo-grid-column field="Action" title="Reject" width="120">
</kendo-grid-column>
<kendo-grid-column field="SelectedRejectedReason" title="SelectedRejectedReasons" width="120" >
</kendo-grid-column>
<kendo-grid-column title="CRT Actions" width="150">
<ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex">
<!--{{rowIndex}}-->
<input type="radio" [name]="generate(rowIndex, 'status')" [id]="generate(rowIndex, 'done')" value="single" class="k-radio"
(change)="setSelectableSettings1($event,dataItem)">
<label class="k-radio-label lbl" [for]="generate(rowIndex, 'done')"> Done </label>
<input type="radio" [name]="generate(rowIndex, 'status')" [id]="generate(rowIndex, 'reject')" value="multiple" class="k-radio"
(change)="setSelectableSettings1($event,dataItem)">
<label class="k-radio-label" [for]="generate(rowIndex, 'reject')"> Reject </label>
</ng-template>
</kendo-grid-column>
<kendo-grid-column title="Status Comment" width="200" >
<ng-template kendoGridCellTemplate let-rowIndex="rowIndex" let-dataItem >
<kendo-dropdownlist [data]="statusCommentSource" [disabled]="DDLdisabled"
[textField]="'NewRejectionReason'"
[valueField]="'RejectionCommentId'"
(selectionChange)="setComment($event,dataItem)">
>
</kendo-dropdownlist>
</ng-template>
</kendo-grid-column>
TS文件代码:
public setSelectableSettings1(e, dataItem): void {
this.gridActionEventData.dataItem = dataItem;
if (e.target.checked) {
if (e.target.id.indexOf("done") > -1) { dataItem.Action = 'Done'; }
else { dataItem.Action = 'Reject';
this.description = dataItem;
}
} else {
if (e.target.id.indexOf("done") > -1) { dataItem.Action = 'Reject'; }
else { dataItem.Action = 'Done'; }
};
if(dataItem.Action == "Reject" )
{
this.DDLdisabled = false;
}
else{ this.DDLdisabled = true;}
}
public setComment(e, dataItem): void
{
this.SelectedRejectedReason = e.NewRejectionReason;
dataItem.SelectedRejectedReason = e.NewRejectionReason;
alert(JSON.stringify(this.SelectedRejectedReason));
}
输出:
答案 0 :(得分:0)
//id-> which dropdown you want to disable/enable
if (your conditon) {
$("#id").kendoDropDownList({ enable: false });
}
else{
$("#id").kendoDropDownList({ enable: false });
}