I have a store locator. Some stores (a very small proportion) have their own home page. I would like to create a hyperlink on the store name in those cases where a hyperlink exists, but leave the others unmarked.
Is this possible?
Yes, it is possible using 'conditional cell data' feature. Little modification required in lib jqgrid_dist.php
search
$row[$col_name] = ( $r ? $c["default"] : '');
and replace with
$row[$col_name] = ( $r ? $c["default"] : $row[$col_name]);
Now, in column definition…
$col = array();
$col["title"] = "Company";
$col["name"] = "company";
$col["width"] = "30";
$col["align"] = "center";
$buttons_html = "<a target='_blank' href={website}'>{company}</a>"; // where website and company both are cols of grid.
$col["default"] = $buttons_html;
// use single quote for condition, and $row will have all columns data, to use in condition
$col["condition"] = '$row["website"] != ""';
$cols[] = $col;
$buttons_html = "<a target='_blank' href={website}'>{company}</a>";
should be
$buttons_html = "<a target='_blank' href='{website}'>{company}</a>";
… but even so, there are 2 issues:
1. The company field is url encoded (showing + instead of spaces). I have tried to fix this both by using the built in php urldecode function and str_replace("+"," ","{company}") but neither removes the +.
2. The website link is part of the data returned via $g-select_command = $SQL; but I have not put it in the grid. It does work (sort of) when I add it to the grid, but I have not worked out how to hide the column (as I don't want it displayed).
The other problem is that the link appears like this:
http://www.mywebsite.com/http%3A%2F%2Fwww.storewebsite.com