如何使用 rowID 参数将重定向按钮添加到 jqGrid
How to add a redirection button to jqGrid with a rowID parameter
我正在使用 jqGrid 在屏幕上显示数据库 table,我需要在每一行的末尾添加一个按钮,将我重定向到另一个页面(我们称之为 page2.php ) 并且将行 ID 的值传递到该页面。
我在 colModel 中添加了一个带有格式化程序的列,但我似乎找不到合适的函数来添加功能按钮(重定向工作正常,但我在传递 ID 时遇到问题):
{name:'refresh', index:'refresh', width:70, align:'center', formatter:refreshButton}
以及对应的函数:
function refreshButton(cellvalue, options, rowobject){
return '<button type="button" onclick="window.location=\'page2.php\'">Go</button>';
}
我在某处发现在 page2.php
之后添加 ?id="+rowid+"&oper=edit
可以传递 rowID,但是重定向将不再起作用...
我很乐意为此提供一些帮助,在此先感谢
每当我点击按钮时,这段代码对我有效
function refreshButton(cellvalue, options, rowobject) {
return '<button type="button" onclick="location.href=\'page2.php?oper=edit&id='+options.rowId+'\'">Go</button>';
}
我正在使用 jqGrid 在屏幕上显示数据库 table,我需要在每一行的末尾添加一个按钮,将我重定向到另一个页面(我们称之为 page2.php ) 并且将行 ID 的值传递到该页面。
我在 colModel 中添加了一个带有格式化程序的列,但我似乎找不到合适的函数来添加功能按钮(重定向工作正常,但我在传递 ID 时遇到问题):
{name:'refresh', index:'refresh', width:70, align:'center', formatter:refreshButton}
以及对应的函数:
function refreshButton(cellvalue, options, rowobject){
return '<button type="button" onclick="window.location=\'page2.php\'">Go</button>';
}
我在某处发现在 page2.php
之后添加 ?id="+rowid+"&oper=edit
可以传递 rowID,但是重定向将不再起作用...
我很乐意为此提供一些帮助,在此先感谢
每当我点击按钮时,这段代码对我有效
function refreshButton(cellvalue, options, rowobject) {
return '<button type="button" onclick="location.href=\'page2.php?oper=edit&id='+options.rowId+'\'">Go</button>';
}