在columnModel中加editoptions使grid表格单元格可编辑怎么做
时间: 2024-03-14 18:43:27 浏览: 151
在使用jqGrid时,可以通过在colModel中使用editoptions属性来使grid表格单元格可编辑。具体步骤如下:
1. 在colModel中设置需要编辑的列的edittype属性为text或者其他支持编辑的类型。
2. 在editoptions属性中设置需要的参数,比如设置输入框的宽度、高度、默认值等。
下面是一个示例:
```
colModel: [
{ name: 'id', index: 'id', width: 60, editable: true },
{ name: 'name', index: 'name', width: 100, editable: true, edittype: 'text',
editoptions: {
size: 20,
maxlength: 30,
defaultValue: 'John Doe'
}
},
{ name: 'age', index: 'age', width: 60, editable: true, edittype: 'text',
editoptions: {
size: 5,
maxlength: 3,
defaultValue: '0'
}
}
]
```
在上面的示例中,name和age列都设置了edittype为text,表示可以进行编辑。同时,在editoptions中设置了一些参数,比如输入框的宽度和默认值等。
注意:使用editoptions属性时,需要将editable属性设置为true,表示该列是可编辑的。
阅读全文
相关推荐













