admin管理员组文章数量:1401593
I have gone through the solutions given for not working onSelectRow but they could not worked for me.
I have following code :
$("#myActions_gridTable").jqGrid({
datatype:'local',
data: myActionsData,
cellsubmit: 'clientArray',
cellEdit: true,
rowNum: noOfLinesToDisplay,
pager: $("#myActions_pager"),
sortname: 'contract_Name',
viewrecords: true,
sortorder: 'asc',
autoWidth:true,
loadonce: true,
cmTemplate: { title: false },
height:'auto',
scrollrows: true,
colNames:["id","Status"],
colModel:[
{
name:'id',index:'id', jsonmap:'id', width:1,hidden:true,key:true, editable:true
},
{name:'status',index:'status', align:'center', sortable: false,
editable: true,
edittype: "select",
width: 150,
editoptions: {
value: "1:Done;2:Running"
}
}
],
onSelectRow : function(id){
console.log('inside onSelectRow');
if (id && id !== lastsel) {
$('#myActions_gridTable').restoreRow(lastsel);
$('#myActions_gridTable').editRow(id, true);
lastsel = id;
}
}
});
Here OnSelectRow does not get fired, no console.log is printed. Please help.
I have gone through the solutions given for not working onSelectRow but they could not worked for me.
I have following code :
$("#myActions_gridTable").jqGrid({
datatype:'local',
data: myActionsData,
cellsubmit: 'clientArray',
cellEdit: true,
rowNum: noOfLinesToDisplay,
pager: $("#myActions_pager"),
sortname: 'contract_Name',
viewrecords: true,
sortorder: 'asc',
autoWidth:true,
loadonce: true,
cmTemplate: { title: false },
height:'auto',
scrollrows: true,
colNames:["id","Status"],
colModel:[
{
name:'id',index:'id', jsonmap:'id', width:1,hidden:true,key:true, editable:true
},
{name:'status',index:'status', align:'center', sortable: false,
editable: true,
edittype: "select",
width: 150,
editoptions: {
value: "1:Done;2:Running"
}
}
],
onSelectRow : function(id){
console.log('inside onSelectRow');
if (id && id !== lastsel) {
$('#myActions_gridTable').restoreRow(lastsel);
$('#myActions_gridTable').editRow(id, true);
lastsel = id;
}
}
});
Here OnSelectRow does not get fired, no console.log is printed. Please help.
Share Improve this question edited Sep 6, 2019 at 9:19 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Jun 4, 2014 at 4:51 p.pradnyap.pradnya 1,0891 gold badge9 silver badges10 bronze badges 5-
It's strange that you use both
cellEdit: true
andeditRow
(inside ofonSelectRow
). Which editing mode you want to implement: cell editing or row editing? Do you definedlastsel
variable? – Oleg Commented Jun 4, 2014 at 5:10 - trirand./jqgridwiki/doku.php?id=wiki:events here 'S' is in capital for variable name 'lastSel', that might be a cause. Do you find any browser console error? – Bhushan Kawadkar Commented Jun 4, 2014 at 5:23
- i don't think it is about the variable name issue .. @BhushanKawadkar – Runcorn Commented Jun 4, 2014 at 5:29
- @Oleg Nothing was working for me so I just tried adding cellEdit also true. – p.pradnya Commented Jun 4, 2014 at 5:48
-
@p.pradnya: Could you include the input data which you use. I find strange that you use
edittype: "select"
witheditoptions: {value: "1:Done;2:Running"}
without usage offormatter: "select"
. Do you use"Done"
and"Running"
strings in the input data or1
or2
? – Oleg Commented Jun 4, 2014 at 7:31
3 Answers
Reset to default 1You need to define the variable lastsel
as
var lastsel;
In the above code you need to do :
var lastsel;
$("#myActions_gridTable").jqGrid({
..............
..............
..............,
onSelectRow : function(id){
console.log('inside onSelectRow');
if (id && id !== lastsel) {
$('#myActions_gridTable').restoreRow(lastsel);
$('#myActions_gridTable').editRow(id, true);
lastsel = id;
}
}
Here is the working JsFiddle Demo
And could get further info here http://www.trirand./jqgridwiki/doku.php?id=wiki:events.
One possible problem could be the usage of edittype: "select"
without usage of formatter: "select"
. In any way the property editoptions: { value: "1:Done;2:Running" }
seems me very suspected if you don't use formatter: "select"
.
How looks the input data for the column "status"
? Do you use 1
and 2
or "Done"
and "Running"
? If you want to hold 1
and 2
values in the data, but you want to display the values as "Done"
and "Running"
then you should use
formatter: "select", edittype: "select", editoptions: {value: "1:Done;2:Running"}
The demo demonstrates it. It uses
var myActionsData = [
{ id: 10, status: 1 },
{ id: 20, status: 2 }
];
as the input.
Alternatively one can use
var myActionsData = [
{ id: 10, status: "Done" },
{ id: 20, status: "Running" }
];
but one should use
edittype: "select", editoptions: {value: "Done:Done;Running:Running"}
in the case. No formatter: "select" are required in the last case: see another demo.
OnSelectrow
is not working when cellEdit
is true.
You can use onCellSelect
instead of OnSelectrow
.
本文标签: javascriptonSelectRow in a JQGridStack Overflow
版权声明:本文标题:javascript - onSelectRow in a JQGrid - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744248861a2597151.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论