Reputation: 6181
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);
},
});
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.
So my question is that how should I set URL
to a custom button in jqGrid.
Upvotes: 0
Views: 1060
Reputation: 221997
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 onClickButton
. So you can really implement any behavior which you need.
Upvotes: 1