jQuery EasyUI - Add link to datagrid cell

Extracted from: http://stackoverflow.com/questions/16061894/jquery-easyui-add-link-to-cell

HTML:

 1 <table id="dgContactSearch" title="Benutzer Suche" class="easyui-datagrid" style="height:160px" 
 2                             url="getContacts.php"
 3                             toolbar="#toolbarContactSearch" pagination="true"
 4                             rownumbers="true" fitColumns="true" singleSelect="true">
 5                         <thead>
 6                             <tr>
 7                                 <th data-options="field:'firma',width:80,align:'left',formatter:formatCustomerId">Kunde</th>
 8                                 <th data-options="field:'name',width:50,align:'left',formatter:formatContactUrl">Name</th>
 9                                 <th field="function" width="50">Funktion</th>
10                                 <th field="phone" width="50">Phone</th>
11                                 <th field="email" width="50">Email</th>
12                                 <th field="mobile" width="50">Mobile</th>
13                                 <th field="fax" width="50">Fax</th>
14 
15                                 <th field="comment" width="120">Kommentare</th>
16                             </tr>
17                         </thead>
18 </table>
 

 Javascript:

 1 <script>
 2 function formatCustomerId(val,row){
 3     var url = "customerView.php?id=";
 4     return '<a href="'+url + row.customer_id+'">'+val+'</a>';
 5 }
 6 
 7 function formatContactUrl(val,row){
 8     var url = "contactView.php?id=";
 9     return '<a href="'+url + row.id+'">'+val+'</a>';
10 }
11 </script>

 

 

 REF:

http://blog.csdn.net/com360/article/details/6537074
http://www.jeasyui.com/documentation/datagrid.php
http://jeasyui.com/demo/main/index.php?plugin=DataGrid
http://www.thinkphp.cn/code/207.html

posted @ 2014-02-14 09:25  emanlee  阅读(2468)  评论(0编辑  收藏  举报