Javascript JQGrid';改变';在change函数中更改gridrow数据后未触发dataevent
我在网格中使用下拉列表。我打算根据dropdown列的更改值更改其他列的值。我的代码如下所示Javascript JQGrid';改变';在change函数中更改gridrow数据后未触发dataevent,javascript,jquery,jqgrid,Javascript,Jquery,Jqgrid,我在网格中使用下拉列表。我打算根据dropdown列的更改值更改其他列的值。我的代码如下所示 dataEvents: [ { type: 'change', fn: function (e) { var row = $("#Grid").closest('tr.jqgrow'); var rowId = $("#Grid").jqGrid('getGridParam', 'selrow'); //alert(rowId); va
dataEvents: [
{
type: 'change',
fn: function (e) {
var row = $("#Grid").closest('tr.jqgrow');
var rowId = $("#Grid").jqGrid('getGridParam', 'selrow');
//alert(rowId);
var rowData = jQuery('#Grid').getRowData(rowId);
rowData.ProductID = e.target.value;
//alert(rowData.ProductID);
$("#Grid").jqGrid('collapseSubGridRow', rowId);
rowData.SelectedOptions = rowData.ProductID + "------";
jQuery('#Grid').setRowData(rowId, rowData);
}
}
]
在编辑模式下,下拉菜单只触发一次更改事件。如果重复更改下拉列表值,则不会触发事件。我在change函数中没有任何代码的情况下尝试了该代码,它运行良好。之后,我发现setRowData函数导致了问题。如果我注释掉setRowData行,那么它可以正常工作
我不确定这种行为。有什么帮助或建议吗?
提前感谢:)我们已经解决了同样的问题,可能会帮助某些人,因为这太简单了: 所以整个事情看起来是这样的:
{ name: 'STOP', index: 'STOP', width: 30 ,editable: true,edittype: 'select',editoptions:{
value: getStopLookup(),
dataEvents: [{type: 'change',
fn: function (e) {
// var rowid = e.target.id;
var row = $(e.target).closest('tr.jqgrow');
var rowid = row.attr('id');
jQuery(grid_selector).saveRow(rowid,
{
succesfunc: function (response)
{
return true;
},
url: '@Url.Action("UpdateStop", "Route")',
mtype: "POST",
aftersavefunc:function (response)
{
ReloadGrid('RoutingDataGrid');
},
});
}
}]
}},
我对网格使用的数据类型是:“local”。我无法找到这种行为的真正原因,但我使用了setCell()函数来更改相应的行数据,结果成功了。如果有人对答案有任何补充,请回复:)