2016-10-25 101 views
0

我正在处理需要编辑剑道网格中的一列的需求。但在网格中,我们会根据条件显示一些列。问题是我们编辑列时,它是以隐藏列开始的。如何编辑MVVM kendo网格中的特定列?

enter image description here

编辑物品栏后显示AreSkusInUse柱: enter image description here

这里是我的MVVM代码:

<div id="BomEditorGrid" 
class="" 
data-role="grid" 
data-resizable="true" 
data-sortable="false" 
data-filterable='{ "extra":false, "operators": { "string": { "contains":"Contains", "doesnotcontain" : "Does not contain", "startswith":"Starts with", "endswith": "Ends with", "eq": "Equal to", "neq" : "Not equal to" } }}' 
data-bind="source: bomEditorDataSource" 
data-editable='{"mode": "incell", "template": kendo.template($("#bomEditorEditTemplate").html()) }' 
data-row-template="bomEditorRowTemplate" 
data-alt-row-template="bomEditorAltRowTemplate" 
data-columns='[ 
{"field": "Selected", "title": "Selected", "filterable": false , "sortable": false, "headerTemplate": kendo.template($("#gridHeaderWithCheckboxTemplate").html()), width: 100}, 
{"field": "AreSkusInUse", "title": "SKUs In Use", hidden: true}, 
{"field": "ItemCd", "title": "Item Code"}, 
{"field": "DesignItemNm", "title": "Item"}, 
{"field": "ChildQty", "title": "Child Qty", "filterable": false, width: 100}, 
{"field": "TemplateDsc", "title": "Template"}, 
{"field": "ParentItemNm", "title": "Parent", hidden: true}, 
{"field": "CreatedByBookNm", "title": "Created By"}, 
{"field": "MaterialTypeCd", "title": "Material Type", hidden: true, "template": kendo.template($("#MaterialTypeColumnTemplate").html())}, 
{"field": "DesignGroup", "title": "DesignGroup", hidden: true}, 
{"field": "CrudType", "title": "Change", "filterable": false} 
]'> 

这里是编辑模板:

<script id="bomEditorEditTemplate" type="text/x-kendo-tmpl"> 
<tr data-uid='#= uid #'> 
    <td><input type="checkbox" class="cb-itemSelected" data-bind='checked:Selected' /></td> 
    # if (BomEditorType === "PFAM") {# 
    <td>#: AreSkusInUse #</td> 
    #}# 
    <td>#: ItemCd #</td> 
    <td>#: DesignItemNm #</td> 
    <td><input type="text" data-bind="value: ChildQty" /></td> 
    # if (MaterialTypeCd !== "DIEN" && MaterialTypeCd !== "FERT") {# 
    <td>#: TemplateDsC#</td> 
    #}# 
    <td>#: CreatedByBookNm #</td> 
    # if (BomEditorType === "FERT") {# 
    <td>#: MaterialTypeCd #</td> 
    #}# 
    <td> <img data-bind="attr:{ class: ChangeIndicatorCssClass}" src="/5/DesignItem/Content/Images/Transparent.gif" /> </td> 
</tr> 

在这里我们可以看到AreSkusInUse列是基于状态显示。

所以我需要两个帮助:
如何使除Child Qty以外的所有列都可编辑为false。
我该如何解决编辑问题。编辑时应显示相应的存档数据。

谢谢

回答

1
  1. “如何使所有的列比儿童数量等为可编辑的假”
    您可以设置的模式来设置字段编辑:假

    ItemCd: { type: "string", editable: false } 
    
  2. “我如何解决编辑问题,编辑时应显示相应的存档数据。”
    在模板中指定的字段值

    <tr data-uid='#=uid#'> 
        <td> 
        <input type="number" value="#:ChildQty#" data-bind="value: ChildQty"> 
        </td> 
    </tr> 
    
相关问题