2017-07-04 61 views
0

在我的剑道网格我想打一个字段不可编辑,我的数据源是通过Ajax调用饶人,我不喜欢以下但不工作:剑道网编辑虚假不工作

$("#turbingrid").kendoGrid({      
    dataSource: result, 
    scrollable: false, 
schema: { 
    model: { 
     id: "DeviceIP", 
     fields: { 
      DeviceIP: { 
       editable:false 
      } 
     } 
    } 
    columns: [ 
     { field: 'DeviceIP', title: 'DeviceIP', width: '100px'}, 
     { field: 'Producer', title: 'Producer', width: '80px'}, 
     editable: "popup" 
}); 
+0

究竟你是“不工作”是什么意思?有错误吗? – Supersnake

+0

@Supersnake不是错误,问题是我不希望设备可编辑,但即使当我设置“可编辑:false”它仍然可编辑! – moris62

回答

0

您不声明schema属性作为kendoGrid初始化的一部分。这些属性属于dataSource。您kendoGrid initilisation前

声明剑道数据源,使用通过Ajax返回的数据,然后使用这个数据源在kendoGrid,如下所示:

var dataSource= new kendo.data.DataSource({ 
    data: result, 
    schema: { 
     model: { 
     id: "DeviceIP", 
     fields: { 
      DeviceIP: { 
       editable:false 
      } 
     } 
     } 
    } 
}); 

而且剑道网格初始化代码如下(注你已经宣布的最后一部分,columnseditable,不正确地):

$("#turbingrid").kendoGrid({      
    dataSource: dataSource, 
    scrollable: false,  
    columns: [ 
     { field: 'DeviceIP', title: 'DeviceIP', width: '100px'}, 
     { field: 'Producer', title: 'Producer', width: '80px'} 
    ], 
    editable: "popup" 
});