Using $col["link"] and $col["linkoptions"] to open a php file within a modal window

QuestionsUsing $col["link"] and $col["linkoptions"] to open a php file within a modal window
Robbie asked 4 years ago

I have a php file which renders a phpgrid. In one column I have a link that I need to have open a different php file, but in a modal window rather than a new browser window.

This is the code which builds the column, where the link is located.

("object_details.php)

$col = array();
$col["title"] = "Location List";
$col["name"] = "locations";
$col["width"] = "35";
$col["align"] = "center";
$col["search"] = false;
$col["sortable"] = false;
$col["link"] = 'javascript:window.open("objects/present_in.php?o_id=$o_id")';
$col["default"] = "DETAILS";

$cols[] = $col;

(present_in.php)

$col = array();
$col["title"] = "Location";
$col["name"] = "locations";
$col["width"] = "15";
$col["align"] = "center";
$col["search"] = false;
$col["sortable"] = false;
$col["default"] = "Locations where this object is present";

$cols[] = $col;

currently it opens a new browser window and keeps the original open with no content. How can I call a function that I can use to open a simple modal, or fancybox to display the grid in php file "present_in.php"?

I can write the function, I am just unsure how to properly call the function from the grid column.

5 Answers
Abu Ghufran answered 4 years ago

You can refer demos/integration/fancy-box.php

# class='fancybox' to open image in fancybox
$col["default"] = "<a class='fancybox' href='http://ssl.gstatic.com/ui/v1/icons/mail/logo_default.png'><img height=25 src='http://ssl.gstatic.com/ui/v1/icons/mail/logo_default.png'></a>&quot;;
$cols[] = $col;

You can replace <img> and href with your text and php page.

You also need to iniclude fancybox resource and JS to attach fancybox (as in demo)

Abu Ghufran answered 4 years ago

If you are using free version,

$col["link"] = 'javascript:window.open("http://www.google.com/?q={name}","newwind","height=500,width=800"); void(0);';

Instead of window.open … you can try calling:
jQuery.fancybox.open({href: "abc.php"});

Here are fancy box includes.

<!– Add fancyBox main JS and CSS files –>
<link type="text/css" rel="stylesheet" href="//cdn.jsdelivr.net/fancybox/2.1.4/jquery.fancybox.css" />
<script type="text/javascript" src="//cdn.jsdelivr.net/fancybox/2.1.4/jquery.fancybox.js"></script>

Robbie answered 4 years ago

Thank you Abud, I should have mentioned I am having difficulty with the style of the fancybox, and was hoping to use jQuery to override inline size attributes, and that was why I wanted to call a function, is that not possible here?

Robbie answered 4 years ago

I am not using the free version, but I will look at the integrating fancybox demo. Thanks

Abu Ghufran answered 4 years ago

Ok, let me know if demo code does not solve your query.

Your Answer

19 + 5 =

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?