仅在编辑模式下禁用列 Syncfusion GRID

问题描述 投票:0回答:2

我尝试仅在编辑模式下使用 EJ2 Grid Syncfusion 禁用列 列代码

columns: [
            { type: 'checkbox', field: 'CheckBox', width: 50 },
            { field: 'id', isPrimaryKey: true, visible: false, headerText: 'id', textAlign: 'Right', width: 120, type: 'number' },
            {
                field: 'modulID', headerText: 'Nama Modul', width: 80, validationRules: { required: true }, allowEditing :false ,
                foreignKeyField: 'id', foreignKeyValue: 'modulName', dataSource: modulComplete
            },
            {
                field: 'departmentID', headerText: 'Department', width: 80, validationRules: { required: false },
                foreignKeyField: 'id', foreignKeyValue: 'departmentName', dataSource: department
            },
            {
                field: 'pegawaiApprover1ID', headerText: 'Pegawai Approver 1', width: 80, validationRules: { required: false },
                foreignKeyField: 'id', foreignKeyValue: 'nama', dataSource: pegawai
            },
            {
                field: 'pegawaiApprover2ID', headerText: 'Pegawai Approver 2', width: 80, validationRules: { required: false },
                foreignKeyField: 'id', foreignKeyValue: 'nama', dataSource: pegawai
            },
            { field: 'officePerusahaanID', visible: false, headerText: 'officeid', textAlign: 'Right', width: 120, type: 'number' },
            { field: 'isApprovedByApprover', width: 40, headerText: 'isApprovedByApprover', type: 'checkbox' },
            { field: 'isApprovedByGA', width: 40, headerText: 'isApprovedByGA', type: 'checkbox' },
            { field: 'isApprovedByCheckin', width: 40, headerText: 'isApprovedByCheckin', type: 'checkbox' },
        ],

但它也会禁用该列的添加操作

有任何信息如何仅在编辑模式下禁用列吗?

谢谢。

javascript syncfusion
2个回答
0
投票

我们已经分析了您的查询,您可以通过启用网格的 isIdentity 列属性来实现您的要求。请找到下面的代码片段,

columns: [
            { type: 'checkbox', field: 'CheckBox', width: 50 },
            { field: 'id', isPrimaryKey: true, visible: false, headerText: 'id', textAlign: 'Right', width: 120, type: 'number' },
            {
                field: 'modulID', headerText: 'Nama Modul', width: 80, validationRules: { required: true }, allowEditing :false , isIdentity: true,
                foreignKeyField: 'id', foreignKeyValue: 'modulName', dataSource: modulComplete
            },
        ],

如果您需要进一步帮助,请联系我们。

问候,

哈里哈兰


0
投票

我的代码是不同的,但对我来说,技巧(在编辑模式下禁用列并在添加操作上启用它)是添加:

isPrimaryKey: true

我在html中的列定义是:

 <e-column field="name" isPrimaryKey="true" headerText="Name" width="100" type="string" [validationRules]="{ required: true, min: [this.nameValidation, 'Name already in use'] }">
© www.soinside.com 2019 - 2024. All rights reserved.