jqGrid将URL设置为自定义按钮 [英] jqGrid set URL to custom button
问题描述
我有一个 jqGrid ,其中我试图实现一个自定义按钮,该按钮会将请求发送到 Servlet .
I have a jqGrid in which I am trying to implement a custom button which will send request to Servlet.
到目前为止,我已经做到了:
So far I have done this:
.navButtonAdd('#pager10',
{
caption:"Activate ",
buttonicon:"ui-icon-add",
position:"last",
mtype: 'POST',
url: 'MyServletName',
Data: {action: 'Activate',custID: function () {return custID;}},
onClickButton: function()
{
alert("Activate "+custID);
},
});
以上代码将Activate
按钮添加到pager
,并且还显示来自onClickButton
事件的警报.但是它不会向 Servlet 发送请求.
Above code adds Activate
button to the pager
and also shows the alert from onClickButton
event. But it doesn't send request to the Servlet.
所以我的问题是我应该如何在jqGrid中的自定义按钮上设置URL
.
So my question is that how should I set URL
to a custom button in jqGrid.
推荐答案
已将自定义按钮添加到导航器栏中,以符合 jQuery.ajax 将任何信息发送到servlet或分配新值到location.href
以重定向到另一个URL.如果需要,您可以使用
Custom button added to navigator bar with respect of navButtonAdd allows to execute any JavaScript code when the user click on the button. So you can implement any action which you need. For example you can use jQuery.ajax to sent any information to the servlet or to assign new value to location.href
to redirect to another URL. If needed you can get the rowid of currently selected row using the code like
var rowid = $(this).jqGrid("getGridParam", "selrow");
.因此,您可以真正实现所需的任何行为. inside of 这篇关于jqGrid将URL设置为自定义按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!onClickButton
. So you can really implement any behavior which you need.