0
我遵循jqgrid文档中创建的规范,但在尝试保存行时发生错误。 这里的示例代码:有关在jqgrid中插入自定义元素的问题
<script>
function myelem (value, options) {
var el = document.createElement("input");
el.type="text";
el.value = value;
return el;
}
function myvalue(elem, operation, value) {
if(type=='get') {
return $(elem).find("input").val();
} else if(type == 'set') {
$('input',elem).val(stringvalue);
}
}
jQuery("#grid_id").jqGrid({
...
colModel: [
...
{name:'price', ..., editable:true, edittype:'custom',
editoptions:{custom_element: myelem, custom_value:myvalue} },
...
]
...
});
</script>
下面一行在调试,我发现这种类型的未定义
是否有其他方法,这一点要知道,如果它是一组或值的获取。
...
if(type=='get') {
...
我看到了操作数的值,但它包含单元格的名称而不是操作的类型 – eKelvin 2011-04-10 07:03:50
@ZeroAbsolute:我试图帮助你,但是你发布的信息太少。例如,您不清楚使用哪种编辑模式(表单编辑,内联编辑或单元格编辑)。每个编辑模式都有自己的代码。例如[这里](https://github.com/tonytomov/jqGrid/blob/v4.0.0/js/grid.formedit.js#L341)和[这里](https://github.com/tonytomov/jqGrid /blob/v4.0.0/js/grid.formedit.js#L575),您可以在表单编辑中看到'get'和'set'。第二个参数在这里是正确的。你应该发布更多你使用的代码。 – Oleg 2011-04-10 10:09:39
@ZeroAbsolute:在内联编辑或单元格编辑的情况下,您只需实现'custom_value'的简化形式,其中第二个参数始终为'get'。可能[一个工作示例](http://www.ok-soft-gmbh.com/jqGrid/Ranking.htm)我准备[答案](http://stackoverflow.com/questions/4842262/jqgrid- custom-cell-integration-of-raty-plugin/4842450#4842450)会帮助你更多。 – Oleg 2011-04-10 10:21:43