Jqgrid单击自定义编辑按钮打开另一个页面 [英] Jqgrid Open another page on clicking a custom edit button

查看:337
本文介绍了Jqgrid单击自定义编辑按钮打开另一个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JQGrid,每行都有一个按钮,点击按钮必须打开一个包含edit.jsp页面的小对话框。我尝试过使用

I have a JQGrid with a button for each row, clicking the button must open a small dialog box looking window containing a edit.jsp page. I've tried using

$("#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有输入框,但它没有加载按钮所在行的值。

but the URL is completely ignored, using it without the URL is out of question since the normal dialogbox that opens up using editGridRow has the input boxes, but it doesn't load the values of the row where the button's at.

我要发布按钮的格式化程序,从这里你可以看到sessionStorage的用法

I'm gonna post the formatter for the button, since here you can see the usage of 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'。)

You should never place the same id values for more as one element on the page (see id='apri' for all buttons).

在我看来,你应该只使用预定义的格式化程序:actions,选项 formatoptions:{editformbutton:true} 。请参阅演示作为示例。可以指定 editGridRow 的其他选项,具体取决于jqGrid的版本和您使用的fork。如果使用免费的jqGrid,您可以在 formEditing 参数内指定所有选项。见 wiki文章了解更多详情。如果使用旧版本的jqGrid,您可以使用 editOptions 属性 formatoptions 中的选项(参见文档)。

It seems to me that you should just use predefined formatter: "actions" with the option formatoptions: { editformbutton: true }. See 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允许您在格式化程序操作中创建自定义按钮。请参阅答案

Free jqGrid allows you to create custom button in formatter actions. See the answer.

如果您确实需要使用自定义格式化,然后我建议你阅读答案这一个,它显示了 beforeSelectRow 回调的用法。

If you really need to use custom formatter then I would recommend you to read the answer and this one, which shows the usage of beforeSelectRow callback.

这篇关于Jqgrid单击自定义编辑按钮打开另一个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆