jQuery EasyUI - Add link to cell
<p>I have 2 tables: Customer Contact. Table contact has a foreign key pointing at the customer table.</p>

<pre><code>&lt;table id="dgContactSearch" title="Suche" class="easyui-datagrid" style="height:160px" 
                            url="getContacts.php"
                            toolbar="#toolbarContactSearch" pagination="true"
                            rownumbers="true" fitColumns="true" singleSelect="true"&gt;
                        &lt;thead&gt;
                            &lt;tr&gt;
                                &lt;th field="customer_id" width="50"&gt;Customer&lt;/th&gt;
                                &lt;th field="name" width="50"&gt;Name&lt;/th&gt;
                                &lt;th field="function" width="50"&gt;Funktion&lt;/th&gt;
                                &lt;th field="phone" width="50"&gt;Phone&lt;/th&gt;
                                &lt;th field="mobile" width="50"&gt;Mobile&lt;/th&gt;
                                &lt;th field="fax" width="50"&gt;Fax&lt;/th&gt;
                                &lt;th field="email" width="50"&gt;Email&lt;/th&gt;
                                &lt;th field="comment" width="50"&gt;Commnent&lt;/th&gt;
                            &lt;/tr&gt;
                        &lt;/thead&gt;
                    &lt;/table&gt;
</code></pre>

<p>here is the php file</p>

<pre><code>$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
    $rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
    $searchItemContact = isset($_POST['searchItemContact']) ? mysql_real_escape_string($_POST['searchItemContact']) : '';

    $searchItemContact = htmlentities($searchItemContact, ENT_QUOTES, 'UTF-8');

    $offset = ($page-1)*$rows;

    $result = array();

    $where = "name like '%$searchItemContact%' OR function like '%$searchItemContact%' OR email like '%$searchItemContact%' OR comment like '%$searchItemContact%'";
    $rs = mysql_query("select count(*) from contact where " . $where);
    $row = mysql_fetch_row($rs);
    $result["total"] = $row[0];

    $rs = mysql_query("select * from contact where " . $where . " limit $offset,$rows");

    $items = array();
    while($row = mysql_fetch_object($rs)){
        array_push($items, $row);
    }
    $result["rows"] = $items;
    echo json_encode($result);
</code></pre>

<p>I want to make the <code>&lt;th field="customer_id" width="50"&gt;Customer&lt;/th&gt;</code> linkable . i.e. <code>&lt;a href="customerView.php?id=$customer_id&gt;#&lt;/a&gt;</code>
So when I load the table I see the customer name instaed of the id and make a link to th e customer page!
Please help.</p>

<p><strong>Update</strong></p>

<p>I managed somehow a little workaround:</p>

<pre><code>&lt;th data-options="field:'name',width:100,align:'left',formatter:formatCustomerId"&gt;Name&lt;/th&gt;
</code></pre>

<p>and then Javascript function that goes along:</p>

<pre><code>function formatCustomerId(val,row){
    var url = "customerView.php?id=";
    return '&lt;a href="'+url + row.customer_id+'"&gt;'+val+'&lt;/a&gt;';
}
</code></pre>
