[英]How to declare closeCell() method for a particular row-item in Angular-JS
我有一個可編輯的網格,但是如果要滿足某些要求,我希望在一行的特定列使其穩定(不可編輯),
這是我的網格的代碼
$scope.Grid = { dataSource : new kendo.data.DataSource({ schema: { model: { id: 'Id', fields: { Id:{type:'number'}, Name: { type: "string" }, Description: { type: "string" }, Remarks: { type: "string" }, ApprovalStatus: { type: "string" } } } } }), selectable: true, sortable: true, resizable: true, scrollable: false, edit: edit, save: update,
這些是我的編輯和更新功能
function edit(e) { e.model.Id = e.model.Id == "" ? 0 : e.model.Id; if(e.model.ApprovalStatus === 'Waiting') { $('#Grid').data("kendoGrid").closeCell(); } } function update(e) { var Data = { Id: e.model.Id != "" && e.model.Id > 0 ? e.model.Id : 0, Name: e.model.Name, Description: e.model.Description, Remarks: e.model.Remarks, ApprovalStatus: e.model.ApprovalStatus } ciSetUp.setPayLoad({ Info: Data }); ciSetUp.postdata(e.model.Id).then(function () { console.log(ciSetUp.postcreatedata); }); }
因此,如果ApprovalStatus等於Waiting,則Approval Status字段應變為不可編輯狀態,而我無法獲取。
直到if條件都可以正常工作,但是循環內的東西不會執行
而不是使用$('#Grid').data("kendoGrid").closeCell();
,請使用e.sender.closeCell();
編輯:以上答案適用於單元incell
編輯模式。 使用inline
編輯模式時,請使用e.sender.cancelRow();
代替。
請參閱此Plunker演示 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.