jqgridjqgrid-formatter

Button in jqgrid


I have been using ng-grid for displaying data and now migrating to jqgrid. I'm a newbie to this tech and I have tried creating a button which performs some other action like validating and opening a new form. I could invoke my Angular JS variable in that button. Can someone help me?

function ActionitmGridformatter(cellvalue, options, rowObject) {
    var itmgrid= "";
    return itmgrid;
}

$scope.itmgrid= function(row){
alert("hii");
...
};

Also the above itmgrid variable is inside the controller. Can someone post useful links for jqgrid docs and any other inputs will be helpful for me. Kindly ignore if the question is repeated and also share the relevant link.

Thanks


Solution

  • I recently needed to do the same thing, I had a grid of ordered products and I needed to create a link in each row that pertained to that order, here is how I went about that:

    Create a function:

    function orderLinkFormatter (cellvalue, options, rowObject) {
                var base = window.location.origin;
                return '<a href="' + base + '/' + cellvalue + '" target="_new">' + rowObject.OrderNumber + '</a>';
            }
    

    In your grid change you colModel to look like this:

    { name: 'OrderId', index: 'OrderId', width: 100, search: false, formatter:orderLinkFormatter, align: 'center'},
    

    You will end up with something like in this DEMO. Or this DEMO

    I would also suggest that you try using free-jqgrid, it is a free fork of jqgrid that is updated almost daily and the author: Oleg provides really good support on this site.