Using cell edit mode in jqGrid, the default behaviour is to enter edit mode on a cell whenever that cell is clicked or if that cell is selected and the enter key is pressed.
在jqGrid中使用单元格编辑模式,默认行为是,只要单击该单元格或者如果选择了该单元格并按下回车键,就会在单元格上进入编辑模式。
Is there a way to change this behaviour so that a single click does not place it in edit mode but a double click does? Entering into edit mode on enter is fine.
有没有办法更改此行为,以便单击不会将其置于编辑模式,但双击?在输入时进入编辑模式很好。
2 个解决方案
#1
2
Directly it is not supported by the cell editing mode, but it seems to me, that you can implement it yourself in the same way as for inline editing (see jqGrid - edit only certain rows for an editable column, for example). You should don't set cellEdit
parameter of jqGrid to true
, but use directly cell editing methods like editCell
described in http://www.trirand.com/jqgridwiki/doku.php?id=wiki:cell_editing#methods.
直接它不受单元格编辑模式的支持,但在我看来,你可以用与内联编辑相同的方式自己实现它(例如,参见jqGrid - 仅编辑可编辑列的某些行)。您不应将jqGrid的cellEdit参数设置为true,而是直接使用http://www.trirand.com/jqgridwiki/doku.php?id=wiki:cell_editing#methods中描述的editCell等单元格编辑方法。
Another way is to use inline editing on double-click instead of cell editing.
另一种方法是在双击而不是单元格编辑时使用内联编辑。
#2
0
First let me thank you in reading your responses I was able to come up with this solution. I needed some specific behavior for cell editing. I needed to be able to select only a single row with a click. No multi select. I needed cell editing that was activated upon a double click. I needed to be able to cancel an edit if a row other than the one selected was clicked. I also needed to be able to restrict user input. My initial google searches brought me here, and I had just about given up hope when I stumbled across other items you had posted.
首先,让我感谢您阅读您的回复,我能够提出这个解决方案。我需要一些特定的细胞编辑行为。我只需要点击就能选择一行。没有多选。我需要在双击时激活的单元格编辑。如果单击所选行以外的行,我需要能够取消编辑。我还需要能够限制用户输入。我最初的谷歌搜索将我带到了这里,当我偶然发现你发布的其他项目时,我只是放弃了希望。
Here is the solution that I came up with. Most of it was from your previous answers. I made some changes. So most of this credit goes to you but I wanted to post it here to help others. This is my first time posting a solution so I hope it is clear and helps.
这是我提出的解决方案。其中大部分来自您之前的答案。我做了一些改变。所以大部分功劳都归你所有,但我想把它发布在这里以帮助别人。这是我第一次发布解决方案,所以我希望它是明确和有帮助的。
edit.iCol. edit.iRow and edit.rowID are stored so that we can do a cancel on the edit. User your own variables here to store these values.
edit.iCol。存储edit.iRow和edit.rowID,以便我们可以对编辑进行取消。在此处使用您自己的变量来存储这些值。
cellEdit: true,
cellsubmit: 'clientArray',
beforeSelectRow: function(rowid) {
if (edit.iRow != null && rowid !== edit.rowID) {
$('#list').jqGrid("restoreCell",edit.iRow, edit.iCol);
edit.iRow = edit.iCol = null;
}
$('#list').jqGrid('setSelection', rowid);
},
afterSaveCell: function (rowid, name, val, iRow, iCol) {
alert("after");
},
beforeSaveCell: function (rowid, name, val, iRow, iCol) {
alert("before");
},
ondblClickRow: function (rowid, iRow,iCol) {
edit.iRow = iRow;
edit.iCol = iCol;
edit.rowID = rowid;
$("#list").editCell(iRow, iCol, true);
}
#1
2
Directly it is not supported by the cell editing mode, but it seems to me, that you can implement it yourself in the same way as for inline editing (see jqGrid - edit only certain rows for an editable column, for example). You should don't set cellEdit
parameter of jqGrid to true
, but use directly cell editing methods like editCell
described in http://www.trirand.com/jqgridwiki/doku.php?id=wiki:cell_editing#methods.
直接它不受单元格编辑模式的支持,但在我看来,你可以用与内联编辑相同的方式自己实现它(例如,参见jqGrid - 仅编辑可编辑列的某些行)。您不应将jqGrid的cellEdit参数设置为true,而是直接使用http://www.trirand.com/jqgridwiki/doku.php?id=wiki:cell_editing#methods中描述的editCell等单元格编辑方法。
Another way is to use inline editing on double-click instead of cell editing.
另一种方法是在双击而不是单元格编辑时使用内联编辑。
#2
0
First let me thank you in reading your responses I was able to come up with this solution. I needed some specific behavior for cell editing. I needed to be able to select only a single row with a click. No multi select. I needed cell editing that was activated upon a double click. I needed to be able to cancel an edit if a row other than the one selected was clicked. I also needed to be able to restrict user input. My initial google searches brought me here, and I had just about given up hope when I stumbled across other items you had posted.
首先,让我感谢您阅读您的回复,我能够提出这个解决方案。我需要一些特定的细胞编辑行为。我只需要点击就能选择一行。没有多选。我需要在双击时激活的单元格编辑。如果单击所选行以外的行,我需要能够取消编辑。我还需要能够限制用户输入。我最初的谷歌搜索将我带到了这里,当我偶然发现你发布的其他项目时,我只是放弃了希望。
Here is the solution that I came up with. Most of it was from your previous answers. I made some changes. So most of this credit goes to you but I wanted to post it here to help others. This is my first time posting a solution so I hope it is clear and helps.
这是我提出的解决方案。其中大部分来自您之前的答案。我做了一些改变。所以大部分功劳都归你所有,但我想把它发布在这里以帮助别人。这是我第一次发布解决方案,所以我希望它是明确和有帮助的。
edit.iCol. edit.iRow and edit.rowID are stored so that we can do a cancel on the edit. User your own variables here to store these values.
edit.iCol。存储edit.iRow和edit.rowID,以便我们可以对编辑进行取消。在此处使用您自己的变量来存储这些值。
cellEdit: true,
cellsubmit: 'clientArray',
beforeSelectRow: function(rowid) {
if (edit.iRow != null && rowid !== edit.rowID) {
$('#list').jqGrid("restoreCell",edit.iRow, edit.iCol);
edit.iRow = edit.iCol = null;
}
$('#list').jqGrid('setSelection', rowid);
},
afterSaveCell: function (rowid, name, val, iRow, iCol) {
alert("after");
},
beforeSaveCell: function (rowid, name, val, iRow, iCol) {
alert("before");
},
ondblClickRow: function (rowid, iRow,iCol) {
edit.iRow = iRow;
edit.iCol = iCol;
edit.rowID = rowid;
$("#list").editCell(iRow, iCol, true);
}