datagrid动态数据添加超链接的方法
2016-04-01 11:22
447 查看
首先,我我们要有一个json格式的datagrid_data.json文件,如下:
其次,在body下有个数据表格,引入json
<table class="easyui-datagrid" style="width:400px;height:250px" data-options="url:'datagrid_data.json',fitColumns:true,singleSelect:true">
<thead>
<tr>
<th data-options="field:'code',width:100">Code</th>
<th data-options="field:'name',width:100,formatter:planUrl">Name</th>
<th data-options="field:'price',width:100,align:'center'">Price</th>
<th data-options="field:'test',width:100">Test</th>
</tr>
</thead>
</table>
然后,在脚本script中,写超链接的方法(跳转的路径,想做的事情)
<link rel="stylesheet" type="text/css" href="../../js/jquery-easyui-1.4.3/themes/metro/easyui.css">
<link rel="stylesheet" type="text/css" href="../../js/jquery-easyui-1.4.3/themes/icon.css">
<script type="text/javascript" src="../../js/jquery-easyui-1.4.3/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="../../js/jquery-easyui-1.4.3/jquery.min.js"></script>
<script type="text/javascript" src="../../js/jquery-easyui-1.4.3/jquery.easyui.min.js"></script>
<script>
//value:绑定列的所有值,row:整个datagrid的所有行,index:绑定列的下标
function planUrl(value,row,index){
if(value){
return "<a href=http://www.baidu.com?code="+row.code +">"+value+"</a>";
}
}
</script>
最后,显示的效果是这样的
其次,在body下有个数据表格,引入json
<table class="easyui-datagrid" style="width:400px;height:250px" data-options="url:'datagrid_data.json',fitColumns:true,singleSelect:true">
<thead>
<tr>
<th data-options="field:'code',width:100">Code</th>
<th data-options="field:'name',width:100,formatter:planUrl">Name</th>
<th data-options="field:'price',width:100,align:'center'">Price</th>
<th data-options="field:'test',width:100">Test</th>
</tr>
</thead>
</table>
然后,在脚本script中,写超链接的方法(跳转的路径,想做的事情)
<link rel="stylesheet" type="text/css" href="../../js/jquery-easyui-1.4.3/themes/metro/easyui.css">
<link rel="stylesheet" type="text/css" href="../../js/jquery-easyui-1.4.3/themes/icon.css">
<script type="text/javascript" src="../../js/jquery-easyui-1.4.3/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="../../js/jquery-easyui-1.4.3/jquery.min.js"></script>
<script type="text/javascript" src="../../js/jquery-easyui-1.4.3/jquery.easyui.min.js"></script>
<script>
//value:绑定列的所有值,row:整个datagrid的所有行,index:绑定列的下标
function planUrl(value,row,index){
if(value){
return "<a href=http://www.baidu.com?code="+row.code +">"+value+"</a>";
}
}
</script>
最后,显示的效果是这样的
相关文章推荐
- C/C++编译常见链接错误
- Android View动画的特殊使用场景
- CentOS6 安装saltstack
- EasyUi中的Combogrid 实现分页和动态搜索远程数据
- word格式刷双击没用时
- JAVA
- php中session的用法
- 欢迎使用CSDN-markdown编辑器
- 集合篇-----ArrayList与LinkedList之间的那些小事
- Android事件分发机制完全解析,带你从源码的角度彻底理解(上)
- Android——pendingIntent详细了解
- 学到的较复杂的 mysql 语名
- 数字与字母 随机数小demo
- CURL常用命令
- 1、jquery知识学习。。。
- Netty线程池概况
- mysql-5.6.17-win32免安装版配置详解
- 自定义 Dialog
- 常用正则表达式
- iOS 开发之照片框架详解之 PhotoKit 详解(上)