column with link and a custom text to display

Questionscolumn with link and a custom text to display
Ali.BH asked 11 years ago

Hi,
First of all, let me thank you for this wonderful php grid.
I have a question that I hope I'll get an answer to.

How can I have a link in a column with a custom text to display?

I'm having the following code:

$col["title"] = “View more”; // caption of column
$col["name"] = “id”; // grid column name, same as db field or alias from sql
$col["link"] = “http://localhost:8080/openpim/trunk/resources/view.php?document_type=rfi&document_id={id}”;

but the result of this is a hyper-link (which is directed to right path) but the text is an integer ( the ID). How can I change this text to something more user friendly, a custom text like “view details”?

4 Answers
varun answered 11 years ago

Capture the URL ID in the new page and by using the GET method and use SQL query to obtain details from the ID related in database,u can get easily what u want to display further.

Abu Ghufran answered 11 years ago

Make 2 columns,

$col["name"] = "id";
$col["hidden"] = true;

and other

$col["title"] = “View more”; // caption of column
$col["name"] = “view_more”; // grid column name, same as db field or alias from sql
$col["link"] = “http://localhost:8080/openpim/trunk/resources/view.php?document_type=rfi&document_id={id}”;

And in select_command query, make sql like ..
select f1,f2,f3, "View Details" as view_more FROM table …"

Ali.BH answered 11 years ago

I managed to achieve this using the following:

$col["title"] = "View Details";
$col["name"] = "id";
$col["default"] = "<a href='http://localhost:8080/openpim/trunk/resources/view.php?document_type=rfi&document_id={id}'>View Details</a>";

$cols[] = $col;

The reason that I did this is because I don't want the column Id to be displayed for the users.

if I use:

$col["name"] = "id";
$col["hidden"] = true;

then the user still can make the column visible using the customize (column) button in the toolbar of the grid.

Abu Ghufran answered 11 years ago

Ok, Thats fine too. I thought you are using free version that why gave an older solution.
You can refer external-link in package too.

Your Answer

16 + 9 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?