I\'m looking for a way to perform \"Add to cart\" ajax call to pass product code (row id) and quantity from other columns in clicked row and redirect to cart page if clicked
showAction
can be used to set the part of URL only. It you want to use the option then you have to use javascript:
prefix (see the answer) to start addToCartOnClick
which mast be defined as the global function.
The better would be to use new option onClick
in formatoptions
of formatter: "showlink"
. I made the corresponding changes of the code of free jqGrid directly after reading of your question. You should refresh the sources which you use from GitHub. Now you can use
{name: "Addtocrt_addtocrt", label: "Add to cart",
search: false, sortable: false, viewable: false,
formatter: "showlink",
formatoptions: {
onClick: function (options) {
// object options contains properties, which could be helpful
// iCol - index of the column in colModel
// iRow - index of the row
// rowid
// cm - element of colModel
// cmName - the same as cm.name
// cellValue: the text inside of `<a>`
// a - DOM element of clicked <a>
// event - Event object of the click event
location.href = "http://www.google.com/";
return false; // it's important to suppress the default a action
}
}}