• datagrid动态数据添加超链接的方法


    首先,我我们要有一个json格式的datagrid_data.json文件,如下:

    其次,在body下有个数据表格,引入json

    <table class="easyui-datagrid" style="400px;height:250px" data-options="url:'datagrid_data.json',fitColumns:true,singleSelect:true">
        <thead>   
            <tr>    
            <th data-options="field:'code',100">Code</th>         
            <th data-options="field:'name',100,formatter:planUrl">Name</th>        
            <th data-options="field:'price',100,align:'center'">Price</th>
            <th data-options="field:'test',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>

    最后,显示的效果是这样的

  • 相关阅读:
    Git编译安装
    ES集群
    索引、分片以及副本的数量和大小原则:
    初识ELK
    zabbix自定义监控项没权限读取文件问题
    Zabbix的图形界面中文变成□□问题
    logrotate
    rsync
    Linux下的mail指令
    nohup
  • 原文地址:https://www.cnblogs.com/xielong/p/5344306.html
Copyright © 2020-2023  润新知