easyui-datagrid中的表结构(列)赋给另一个 easyui-datagrid组件

页面上有两个  easyui-datagrid 组件

grid 用于显示

grid_toexcel 用于导出

目的 将 grid 克隆至 grid_toexcel  使 grid_toexcel 与 grid 的表结构完(列)全一样,但数据并不克隆

html

复制代码
<table id='grid' class='easyui-datagrid' style='width:1250px;min-height:450px'  
            title='列表' iconCls='icon-table' pagination='true' rownumbers='true' fitColumns='true' singleSelect='true' toolbar='#toolbar' >   
            <!-- rownumbers='true' fitColumns='true' singleSelect='true' toolbar='#toolbar'  remoteSort='false'>   不分页 -->
        <thead>  
            <tr>  
                <th field='agent_name' width='25'align='center' sortable='true' >坐席工号</th> 
                <th field='user_name' width='25'align='center' sortable='true' >坐席员</th> 
 
                <th field='start_time' width='40'align='center' sortable='true' >开始时间</th>
                <th field='stop_time' width='40'align='center' sortable='true' >结束时间</th> 
                <th field='time_len' width='20'align='center' sortable='true' >时长</th> 
                <th field='time_len_s' width='20'align='center' sortable='true' >时长(秒)</th> 
                <th field='status' width='20'align='center' sortable='true' >状态</th>  

                <th field='description' width='80'align='center' sortable='true' >描述</th> 
            </tr>  
        </thead>  
    </table>  
    <div id='div_toexcel' class='easyui-panel' closed='true'><!-- 用于导出 -->
        <table id='grid_toexcel' class='easyui-datagrid'> 
        </table>  
    </div>
复制代码

js

//var cols = $('#grid').datagrid('getColumnFields'); //获取所有列名
//将grid的表结构(列名)赋给grid_toexcel
var cols=$('#grid').datagrid('options').columns; //获取所有列的json对象
//console.log(cols[0]); 
$('#grid_toexcel').datagrid({columns:[cols[0]]}).datagrid("reload");

 

posted @   海乐学习  阅读(73)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
历史上的今天:
2022-06-14 帝国CMS 标签 showclasstemp
2022-06-14 帝国CMS 标签 phomenews
2022-06-14 帝国CMS 标签 ecmsinfo
2022-06-14 帝国CMS 标签 listsonclass
2018-06-14 html input 文本框 只能输入数字,包含输小数点.
点击右上角即可分享
微信分享提示