JQGrid, value in grid to redirect to a specific Action

39 Views Asked by At
(function () {
    ("#user_rep_stats").jqGrid({
        url: actionUrl("GetUserReplicationStatistics", "ExternalUserReplications", null, "ThirdPartyReports"),
        postData: $("#form_filter").serializeObject(),
        datatype: "json",
        colNames: ['', 'External BD', 'User', 'Replications', 'First Replication', 'Last Replication', 'Close/Cancel Day'],
        colModel: [
            { name: 'UserId', index: 'UserId', align: 'center', hidden: true },
            { name: 'ExternalUserId', index: 'ExternalUserId', align: 'center', hidden: true },
            { name: 'ExternalBDTrimmed', index: 'ExternalBDTrimmed', fixed: true, width: 200 },
            { name: 'User', index: 'User', fixed: true, width: 80 },
            { name: 'NumberOfReplications', index: 'NumberOfReplications', template: numberTemplate, fixed: true, width: 100 },
            { name: 'FirstReplicationStr', index: 'FirstReplicationStr', fixed: true, align: 'center', width: 125 },
            { name: 'LastReplicationStr', index: 'LastReplicationStr', fixed: true, align: 'center', width: 125 },
            { name: 'VisitCloseTime', index: 'VisitCloseTime', template: dateTimeTemplate, fixed: true, width: 142 }

I have a query from Oracle that returns users replications to DB. I need to have the ExternalBDTrimmed (which is returned from query and has ExternalUserId (hidden in grid) also returned from query. I need to make the result ExternalBDTrimmed to be a link, once clicked to redirect to another controller/action and pass the ExternalUserId to that action. I tried making a custom formatter but with no success...

1

There are 1 best solutions below

0
Tony Tomov On

In your case you will need to define your own custom formatter. As of documentation the the 3 parameter is a rowObject where the definition is

rowObject is a row data represented in the format determined from datatype option. If we have datatype: xml/xmlstring - the rowObject is xml node, provided according to the rules from xmlReader. If we have datatype: json/jsonstring - the rowObject is object, provided according to the rules from jsonReader

having this you can easy construct your formatter suppose the data is json

function myLinkFormatter (cellvalue, options, rowObject) {
    return "<a href='mynink.php?ExternalUserId="+rowObject.ExternalUserId+"'>"+rowObject.ExternalBDTrimmed+"</a>";
}