How to perform ajax call and redirect to other page if clicked in free jqgrid column

前端 未结 1 777
悲&欢浪女
悲&欢浪女 2020-12-22 03:15

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

相关标签:
1条回答
  • 2020-12-22 03:46

    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
            }
        }}
    
    0 讨论(0)
提交回复
热议问题