Jqgrid 点击自定义编辑按钮打开另一个页面

Jqgrid Open another page on clicking a custom edit button

我有一个 JQGrid,每行都有一个按钮,单击该按钮必须打开一个看起来 window 的小对话框,其中包含一个 edit.jsp 页面。我试过使用

$("#list").on("click", "#apri", function(){                 
            var id =sessionStorage.getItem("idProdotto");
            $("#list").jqGrid('editGridRow', id, {height:280,url:"http://localhost:8080/SaGE2/prodotti/edit" ,reloadAfterSubmit:false});                
        });

但是 URL 被完全忽略,没有 URL 使用它是不可能的,因为使用 editGridRow 打开的普通对话框有输入框,但它不会加载按钮所在行的值。

我要 post 按钮的格式化程序,因为在这里您可以看到 sessionStorage

的用法
function bottone (cellvalue, options, rowObject)
        {          
           return "<div style='margin-bottom: 5px; margin-top: 5px;'>" +  
           "<button id='apri' onclick="+sessionStorage.setItem("idProdotto", rowObject.id)+"> Apri </button></div>";

        }

永远不要为页面上的一个元素放置相同的 id 值(请参阅 id='apri' 了解所有按钮)。

在我看来,您应该只使用带有选项 formatoptions: { editformbutton: true } 的预定义 formatter: "actions"。参见 the demo as an example. Other options of editGridRow can be specified depend on the version of jqGrid and the fork which you use. In case of usage free jqGrid you can specify all options inside of formEditing parameter. See the wiki article for more details. In case of usage old version of jqGrid you can use the options inside of editOptions property of formatoptions (see the documentation)。

免费的 jqGrid 允许您在格式化程序操作中创建自定义按钮。参见

如果您真的需要使用自定义格式化程序,那么我建议您阅读 the answer and this one,其中显示了 beforeSelectRow 回调的用法。