Creating a dynamic link using phpgrid

I am using phpgrid.com datagrid and want to create a dynamic grid for my "kbid" column. I saw an example on my page as follows:

$dg -> set_col_dynalink("productCode", "http://www.example.com/", "productCode", '&foo=bar'); 

I did the same:

$dg -> set_col_dynalink("kbid", "../ib/detail.php", "kbid");

Now it shows:

local / reskb / IB / detail.php? Kbid = one thousand one hundred forty three

but i need to do it like

local / reskb / IB / detail.php offset = 0 &? KBID = 4916

here the offset is the line number.

+4
source share
2 answers

You are trying to manipulate a hyperlink to pass an extra parameter through a URL. You must do this in the client with Javascript.

Here is an example from phpGrid that calls the javascript function when the user clicks a hyperlink in the grid. Here is the link:

http://phpgrid.com/example/call-javascript-function-on-hyperlink-click/

(http://phpgrid.com/documentation/enable_rownumbers/)

PHP

$dg->set_col_format("productLine", "showlink", array("baseLinkUrl"=>"javascript:", "target"=>"_self",
    "showAction"=>"myFunction(jQuery('#products'),'", 
    "addParam"=>"');")); 

Javascript

    myFunction = function (grid,param) {
        var ar = param.split('=');
        if (grid.length > 0 && ar.length === 2 && ar[0] === '?id') {
            var rowid = ar[1];
            var kbid = grid.getCell(rowid, 'kbid');
            var rowNum = grid.getInd(rowid);
            window.location.href = "http://example.com/?offset="+ rowNum +"&kbid="+kbid;
        }
    };

getInd , : http://www.trirand.com/jqgridwiki/doku.php?id=wiki:methods

+5

? - .

, , javascript .

$dg -> set_col_dynalink("productLine",
    "http://www.example.com/",
    "productName",
    '"+(rowIndex)+"');
0

All Articles