KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Table row as a link #1132

Closed Jeno Haraszti opened this topic on on Oct 18, 2019 - 3 comments

Jeno Haraszti commented on Oct 18, 2019

Hi,

Is it possible to make an entire table row a link?

Formatting a column with

"formatValue"=>function($value){
    return "<a href='item.php?name=$value'>$value</a>";
} 

does the trick for one column, but not the entire row.

Appreciate your help.

Thanks.

KoolReport commented on Oct 19, 2019

May be you can look at the clientEvent of table:

Table::create(array(
    "clientEvents"=>array(
        "rowClick"=>"function(params){
            //params.rowData
            //params.rowIndex
            //In here, you can write javascript to redirect.
            window.location.href = "http://somehere.com";
        }"
    )
));

Basically you write a javascript function on the event of row clicked and redirect browser to somewhere. You can get the rowData as well as rowIndex from handle function's parameter.

Jeno Haraszti commented on Oct 19, 2019

Thank you. I will try it later and let you know the result.

Jeno Haraszti commented on Oct 22, 2019

Hi,

It worked out nicely.

First I needed to add a hidden column to the table in order to get a reference id. I made the hidden column by:

"cssStyle"=>array("td"=>"display:none","th"=>"display:none","tf"=>"display:none"),

Then I applied the rowClick event as: `

"clientEvents"=>array(
		"rowClick"=>"function(params){
        window.location.href = 'http://somehere.com/?' + params.rowData['some_id'] ;
		}"
	    ),

Thanks for your help!

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed
solved

None