easyui datagrid Column Group column groups, complex nested table header header head assembly (reproduced)

source:

https://blog.csdn.net/link_zz/article/details/10237099

https://www.cnblogs.com/nangong/p/ccdfabb7ccedbfa580acc6eeef286a27.html

As shown below:

 

 

 

A, javascript way

<Script type = "text / JavaScript">
    
    var DataGrid;
    $ (function () {
        $ ( '# DataGrid') DataGrid ({.
            URL: '{: the U-( "the Admin / Article This article was / indexjson")}',
            title: '',
            iconCls: 'icon-Save',
            Fit: to true,
            // following page strip
            the pagination: to true,
            the pageSize: 14,
            pageList: [14,20,30,40,50],
            // whether the horizontal scroll bar appears
            fitColumns: to true,
            // data wrap
            nowrap: false,
            border: false,
            // you choose to help you remember before, do cross-page delete
            idField: 'the above mentioned id',
            the Columns:[[{
                        title:'',
                        field:'ck',
                        checkbox:true,
                        width:10,
                        rowspan:2
            },{
                        title:'ID',
                        field:'id',
                        width:50,
                        rowspan:2,
                        align:'center'
            },{
                        title:'文章标题',
                        field:'title',
                        width:350,
                        rowspan:2
            },{
                        title:'属性',
                        align:'center',
                        colspan:3
            }, {
                        Title: 'respective sections',
                        Field: 'name',
                        width: 150,
                        rowspan: 2
            }, {
                        title: 'relevant topics',
                        Field: 'name',
                        width: 150,
                        rowspan: 2
            }, {
                        title : 'time',
                        Field: 'time',
                        width: 150,
                        align = left: 'Center',
                        rowspan: 2
            }
        ], [
            {
                        title:'recommend',
                        field:'good',
                        width:50,
                        align:'center'
            },{
                        title:'热门',
                        field:'hits',
                        width:50,
                        align:'center'
            },{
                        title:'图',
                        field:'pic',
                        width:50,
                        align:'center'
            },
            
        ]],toolbar:"#tb"
        });
    });
    
    function doSearch(value){
        //alert('You input: ' + value);
         $('#datagrid').datagrid('load',{
             title:$('#tb').find('[name=search]').val()
        });


    }
    
    function doAdd(){
        //alert('You input: ' + value);
        
    }
    
    function doSave(value){
        alert('You input: ' + value);
    }
    
    function doDel(value){
        alert('You input: ' + value);
    }
    
//    function doSearch(value){
//        alert('You input: ' + value);
//    }


</script>

Column data table is an array of objects, i.e., the elements of this object is an array (Array js object). Subject object in each array element is configurable, each define a column configuration object. Note nested array of objects written form
note of these two properties is the key field nested column, you must have

 rowspan: 2 // spread over two lines

colspan: 3 // accounted for three


Two, html mode

http://www.jeasyui.net/demo/334.html

<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>Column Group - jQuery EasyUI Demo</title>
	<link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="../../themes/icon.css">
	<link rel="stylesheet" type="text/css" href="../demo.css">
	<script type="text/javascript" src="../../jquery.min.js"></script>
	<script type="text/javascript" src="../../jquery.easyui.min.js"></script>
</head>
<body>
	<h2>Column Group</h2>
	<p>The header cells can be merged. Useful to group columns under a category.</p>
	<div style="margin:20px 0;"></div>
	<table class="easyui-datagrid" title="Column Group" style="width:700px;height:250px"
			data-options="rownumbers:true,singleSelect:true,url:'datagrid_data1.json',method:'get'">
		<thead>
			<tr>
				<th data-options="field:'itemid',width:80" rowspan="2">Item ID</th>
				<th data-options="field:'productid',width:100" rowspan="2">Product</th>
				<th colspan="4">Item Details</th>
			</tr>
			<tr>
				<th data-options="field:'listprice',width:80,align:'right'">List Price</th>
				<th data-options="field:'unitcost',width:80,align:'right'">Unit Cost</th>
				<th data-options="field:'attr1',width:240">Attribute</th>
				<th data-options="field:'status',width:60,align:'center'">Status</th>
			</tr>
		</thead>
	</table>
 
</body>
</html>

  

 

Guess you like

Origin www.cnblogs.com/hao-1234-1234/p/11847497.html