jQuery EasyUI从入门到精通(19)DataGrid(9)

2025-11-16 00:04:46

1、DataGrid Cell Style(数据表格单元格风格),The cells which listprice value is less than 30 are highlighted.

<!DOCTYPE html>

<html>

<head>

    <meta charset="UTF-8">

    <title>DataGrid Cell Style - 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>DataGrid Cell Style</h2>

    The cells which listprice value is less than 30 are highlighted.

    <div style="margin:20px 0;"></div>

    <table class="easyui-datagrid" title="DataGrid Cell Style" style="width:700px;height:250px"

            data-options="裹互

                singleSelect: true,

                iconCls: 'icon-save',

                url: 'datagrid_data1.json',

                method: 'get'

            "诉陵处>

        <thead>

            <tr>

                <th data-options="field:'itemid',width:80">Item ID</th>

                <th data-options="field:'productid',width:100">Product</th>

                <th data-options="field:'listprice',width:80,align:'right',styler:cellStyler">List Price</th>

                <th data-options="field:'unitcost',width:80,align:'right'">Unit Cost</th>

                <th data-options="field:'attr1',width:250">Attribute</th>

                <th data-options="field:'status',width:60,align:'center'">Status</th>

            </tr>

        </thead>

    </table>

    <script type="text/javascript">

        function cellStyler(value,row,index){

            if (value < 30){

                return 'background-color:#ffee00;color:red;';

            }

        }

    </script>

</body>

</html>

jQuery EasyUI从入门到精通(19)DataGrid(9)

2、DataGrid Cell Style(数据表格单元格风格),运行效果如下图块撤所示。

jQuery EasyUI从入门到精通(19)DataGrid(9)

3、Footer Rows in DataGrid(数据表格的尾行),The summary informations can be displayed in footer rows(汇总信息可以被显示在尾行).

<!DOCTYPE html>

<html>

<head>

    <meta charset="UTF-8">

    <title>Footer Rows in DataGrid - 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>Footer Rows in DataGrid</h2>

    The summary informations can be displayed in footer rows.

    <div style="margin:20px 0;"></div>

    <table class="easyui-datagrid" title="Footer Rows in DataGrid" style="width:700px;height:220px"

            data-options="

                url: 'datagrid_data2.json',

                method: 'get',

                fitColumns: true,

                singleSelect: true,

                rownumbers: true,

                showFooter: true

            ">

        <thead>

            <tr>

                <th data-options="field:'itemid',width:80">Item ID</th>

                <th data-options="field:'productid',width:120">Product ID</th>

                <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:250">Attribute</th>

                <th data-options="field:'status',width:60,align:'center'">Status</th>

            </tr>

        </thead>

    </table>

</body>

</html>

jQuery EasyUI从入门到精通(19)DataGrid(9)

4、Footer Rows in DataGrid(数据表格的尾行),运行效果如下图所示。

jQuery EasyUI从入门到精通(19)DataGrid(9)

5、Merge Cells for DataGrid(数据表格合并单元格),Cells in DataGrid body can be merged(数据表格体中的单元格可以被合并).

<!DOCTYPE html>

<html>

<head>

    <meta charset="UTF-8">

    <title>Merge Cells for DataGrid - 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>Merge Cells for DataGrid</h2>

    Cells in DataGrid body can be merged.

    <div style="margin:20px 0;"></div>

    <table class="easyui-datagrid" title="Merge Cells for DataGrid" style="width:700px;height:250px"

            data-options="

                rownumbers: true,

                singleSelect: true,

                iconCls: 'icon-save',

                url: 'datagrid_data1.json',

                method: 'get',

                onLoadSuccess: onLoadSuccess

            ">

        <thead>

            <tr>

                <th data-options="field:'productid',width:100">Product</th>

                <th data-options="field:'itemid',width:80">Item ID</th>

                <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>

    <script type="text/javascript">

        function onLoadSuccess(data){

            var merges = [{

                index: 2,

                rowspan: 2

            },{

                index: 5,

                rowspan: 2

            },{

                index: 7,

                rowspan: 2

            }];

            for(var i=0; i<merges.length; i++){

                $(this).datagrid('mergeCells',{

                    index: merges[i].index,

                    field: 'productid',

                    rowspan: merges[i].rowspan

                });

            }

        }

    </script>

</body>

</html>

jQuery EasyUI从入门到精通(19)DataGrid(9)

6、Merge Cells for DataGrid(数据表格合并单元格),运行效果如下图所示。

jQuery EasyUI从入门到精通(19)DataGrid(9)

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢