本地jqGrid单元格编辑 [英] jqGrid Cell Editing Locally
问题描述
我试图用可编辑单元实现一个jqGrid:
var myGrid = $(#mygrid)。 jqGrid({
datatype:'local',
data:mydata,
colModel:[
{name:'Serial',width:1040,editable:true,edittype:'文本'}
],
rowNum:10,
rowList:[10,20,30],
pager:'#mypager',
sortname:'Serial ',
cellEdit:true,
viewrecords:true,
sortorder:desc,
onSelectRow:function(id){
if(id&& id!== lastSel){
jQuery('#mygrid')。restoreRow(lastSel);
lastSel = id;
}
jQuery('#mygrid')。editRow (id,true);
}
});
myGrid.jqGrid('navGrid','#mypager',{edit:true,add:false,del:false,search:true});
然而,每次我尝试编辑一个单元格时,它都允许我在它上面编写,但只要另一件事,每次我点击输入时,它都会尝试提交一些内容,因为它向我显示了以下内容消息:
没有设置网址。
当然,我只想在本地使用这个网格。编辑网格后,用户将不得不单击包含在.html中的提交按钮,然后我将管理插入到网格上的数据。
Thx。
为了能够使用在本地编辑单元格(您使用 cellEdit:true
),您必须使用 cellsubmit:'clientArray'属性。
另一方面,您也可以使用 editRow 功能,因此您想要使用内联编辑 。为了能够在本地使用内联编辑,您应该定义 editurl:'clientArray'
(参见 myGrid.jqGrid('navGrid','#mypager')。
我建议您只使用 Inline Editing 并包含 editurl:'clientArray'
到你的jqGrid的选项。 单元格编辑( cellEdit:true
)和表单编辑应该是删除。
I'm trying to implement a jqGrid with editable cells:
var myGrid = $("#mygrid").jqGrid({
datatype: 'local',
data: mydata,
colModel: [
{ name: 'Serial', width: 1040, editable: true, edittype: 'text' }
],
rowNum: 10,
rowList: [10, 20, 30],
pager: '#mypager',
sortname: 'Serial',
cellEdit: true,
viewrecords: true,
sortorder: "desc",
onSelectRow: function(id){
if(id && id!==lastSel){
jQuery('#mygrid').restoreRow(lastSel);
lastSel=id;
}
jQuery('#mygrid').editRow(id, true);
}
});
myGrid.jqGrid('navGrid', '#mypager', { edit: true, add: false, del: false, search: true });
However, everytime I try to edit a cell, it allows me to write on it but as soon as I click on other row or even outside the grid, the text dissapear.
Another thing, everytime I hit "enter" it tries to submit something because it shows me the following message: "No url is set".
And of course, I only want to use this grid 'locally'. After editing the grid the user will have to click on a "Submit" button that is included in the .html and then I will manage the data inserted on the grid.
Thx.
To be able to use cell editing locally (you use cellEdit:true
) you have to use cellsubmit:'clientArray' property.
On the other side you use also editRow function, so you want to use Inline Editing. To be able to use Inline Editing locally you should define editurl:'clientArray'
(see documentation here).
More then that you use also myGrid.jqGrid('navGrid', '#mypager', { edit: true, ...})
which enable Form Editing, which has not full local editing support.
I recommend you to use just Inline Editing and include editurl:'clientArray'
to the options of your jqGrid. The cell editing (cellEdit: true
) and Form Editing should be removed.
这篇关于本地jqGrid单元格编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!