首页 > 代码库 > 用JavaScript方式创建easyUI datagrid Column Group(列组)

用JavaScript方式创建easyUI datagrid Column Group(列组)

技术分享

代码如下:

 

[javascript] view plain copy
 
  1. <script type="text/javascript">  
  2.       
  3.     var datagrid;  
  4.     $(function(){  
  5.         $(‘#datagrid‘).datagrid({  
  6.             url:‘{:U("Admin/Article/indexjson")}‘,  
  7.             title:‘‘,  
  8.             iconCls:‘icon-save‘,  
  9.             fit:true,  
  10.             //下面的page条  
  11.             pagination:true,  
  12.             pageSize:14,  
  13.             pageList:[14,20,30,40,50],  
  14.             //是否出现横向滚动条  
  15.             fitColumns:true,  
  16.             //数据折行  
  17.             nowrap:false,  
  18.             border:false,  
  19.             //帮你记住你选过的,做跨页删除  
    1.            idField:‘id‘,  
    2.             columns:[[{  
    3.                         title:‘‘,  
    4.                         field:‘ck‘,  
    5.                         checkbox:true,  
    6.                         width:10,  
    7.                         rowspan:2  
    8.             },{  
    9.                         title:‘ID‘,  
    10.                         field:‘id‘,  
    11.                         width:50,  
    12.                         rowspan:2,  
    13.                         align:‘center‘  
    14.             },{  
    15.                         title:‘文章标题‘,  
    16.                         field:‘title‘,  
    17.                         width:350,  
    18.                         rowspan:2  
    19.             },{  
    20.                         title:‘属性‘,  
    21.                         align:‘center‘,  
    22.                         colspan:3  
    23.             },{  
    24.                         title:‘所属栏目‘,  
    25.                         field:‘name‘,  
    26.                         width:150,  
    27.                         rowspan:2  
    28.             },{  
    29.                         title:‘所属专题‘,  
    30.                         field:‘name‘,  
    31.                         width:150,  
    32.                         rowspan:2  
    33.             },{  
      1.                         title:‘发布时间‘,  
      2.                         field:‘time‘,  
      3.                         width:150,  
      4.                         align:‘center‘,  
      5.                         rowspan:2  
      6.             }  
      7.         ],[  
      8.             {  
      9.                         title:‘推荐‘,  
      10.                         field:‘good‘,  
      11.                         width:50,  
      12.                         align:‘center‘  
      13.             },{  
      14.                         title:‘热门‘,  
      15.                         field:‘hits‘,  
      16.                         width:50,  
      17.                         align:‘center‘  
      18.             },{  
      19.                         title:‘图‘,  
      20.                         field:‘pic‘,  
      21.                         width:50,  
      22.                         align:‘center‘  
      23.             },  
      24.               
      25.         ]],toolbar:"#tb"  
      26.         });  
      27.     });  
      28.       
      29.     function doSearch(value){  
      30.         //alert(‘You input: ‘ + value);  
      31.          $(‘#datagrid‘).datagrid(‘load‘,{  
      32.              title:$(‘#tb‘).find(‘[name=search]‘).val()  
      33.         });  
        1.  }  
        2.       
        3.     function doAdd(){  
        4.         //alert(‘You input: ‘ + value);  
        5.           
        6.     }  
        7.       
        8.     function doSave(value){  
        9.         alert(‘You input: ‘ + value);  
        10.     }  
        11.       
        12.     function doDel(value){  
        13.         alert(‘You input: ‘ + value);  
        14.     }  
        15.       
        16. //    function doSearch(value){  
        17. //        alert(‘You input: ‘ + value);  
        18. //    }  
        19.   
        20.   
        21. </script>  

用JavaScript方式创建easyUI datagrid Column Group(列组)