JQuery DataGrid 合并标题

页面:<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 <title>jQuery EasyUI</title>
 <link rel="stylesheet" type="text/css" href="../themes/default/easyui.css">
 <link rel="stylesheet" type="text/css" href="../themes/icon.css">
 <script type="text/javascript" src="../jquery-1.4.4.min.js"></script>
 <script type="text/javascript" src="../jquery.easyui.min.js"></script>
 <script>
  $(function(){
   $('#test').datagrid({
    title:'My Title',
    iconCls:'icon-save',
    width:600,
    height:350,
    nowrap: false,
    striped: true,
    collapsible:true,
    url:'datagrid_data.json',
    sortName: 'code',
    sortOrder: 'desc',
    remoteSort: false,
    idField:'code',
    frozenColumns:[[
                 {field:'ck',checkbox:true},
                 {title:'code',field:'code',width:80,sortable:true}
    ]],
    columns:[[
           {title:'Base Information',colspan:3},
     {field:'opt',title:'Operation',width:100,align:'center', rowspan:2,
      formatter:function(value,rec){
       return '<span style="color:red">Edit Delete</span>';
      }
     }
    ],
    [
     {field:'name',title:'Name',width:120},
     {field:'addr',title:'Address',width:120,rowspan:2,sortable:true,
      sorter:function(a,b){
       return (a>b?1:-1);
      }
     },
     {field:'col4',title:'Col41',width:150,rowspan:2}
    ]],
    pagination:true,
    rownumbers:true,
    toolbar:[{
     id:'btnadd',
     text:'Add',
     iconCls:'icon-add',
     handler:function(){
      $('#btnsave').linkbutton('enable');
      alert('add')
     }
    },{
     id:'btncut',
     text:'Cut',
     iconCls:'icon-cut',
     handler:function(){
      $('#btnsave').linkbutton('enable');
      alert('cut')
     }
    },'-',{
     id:'btnsave',
     text:'Save',
     disabled:true,
     iconCls:'icon-save',
     handler:function(){
      $('#btnsave').linkbutton('disable');
      alert('save')
     }
    }]
   });
   var p = $('#test').datagrid('getPager');
   if (p){
    $(p).pagination({
     onBeforeRefresh:function(){
      alert('before refresh');
     }
    });
   }
  });
  function resize(){
   $('#test').datagrid('resize', {
    width:700,
    height:400
   });
  }
  function getSelected(){
   var selected = $('#test').datagrid('getSelected');
   if (selected){
    alert(selected.code+":"+selected.name+":"+selected.addr+":"+selected.col4);
   }
  }
  function getSelections(){
   var ids = [];
   var rows = $('#test').datagrid('getSelections');
   for(var i=0;i<rows.length;i++){
    ids.push(rows[i].code);
   }
   alert(ids.join(':'));
  }
  function clearSelections(){
   $('#test').datagrid('clearSelections');
  }
  function selectRow(){
   $('#test').datagrid('selectRow',2);
  }
  function selectRecord(){
   $('#test').datagrid('selectRecord','002');
  }
  function unselectRow(){
   $('#test').datagrid('unselectRow',2);
  }
  function mergeCells(){
   $('#test').datagrid('mergeCells',{
    index:2,
    field:'addr',
    rowspan:2,
    colspan:2
   });
  }
 </script>
</head>
<body>
 <h1>DataGrid</h1>
 <div style="margin-bottom:10px;">
  <a href="#" οnclick="resize()">resize</a>
  <a href="#" οnclick="getSelected()">getSelected</a>
  <a href="#" οnclick="getSelections()">getSelections</a>
  <a href="#" οnclick="clearSelections()">clearSelections</a>
  <a href="#" οnclick="selectRow()">selectRow</a>
  <a href="#" οnclick="selectRecord()">selectRecord</a>
  <a href="#" οnclick="unselectRow()">unselectRow</a>
  <a href="#" οnclick="mergeCells()">mergeCells</a>
 </div>
 
 <table id="test"></table>
 
</body>
</html>

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值