EasyUI Forum
April 19, 2024, 07:31:28 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Datalist Group and Subgroups  (Read 4607 times)
zombie86
Newbie
*
Posts: 24


View Profile WWW Email
« on: September 10, 2021, 11:58:05 AM »

Hi All,

is there a way to Group Datalist in Hierarchy way as below

First Group Header "General Ledger"
First Subgroup No. 1 Header "Accounts"
First Subgroup No. 1 Items "View Accounts", "Add Accounts", "Edit Accounts", "Disable Accounts"

First Subgroup No. 2 Header "Journals"
First Subgroup No. 2 Items "View Journals", "Add Journals", "Edit Journals", "Void Journals", "Approve Journals"

and so on..

please any help is appreciated
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 on: September 10, 2021, 09:13:07 PM »

Please refer to the SubGrid example.

https://www.jeasyui.com/demo/main/index.php?plugin=DataGrid&theme=material-teal&dir=ltr&pitem=Nested%20SubGrid&sort=asc

Code:
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>jQuery EasyUI</title>
    <link rel="stylesheet" type="text/css" href="https://www.jeasyui.com/easyui/themes/material-blue/easyui.css">
    <link rel="stylesheet" type="text/css" href="https://www.jeasyui.com/easyui/themes/icon.css">
    <script type="text/javascript" src="https://www.jeasyui.com/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="https://www.jeasyui.com/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="https://www.jeasyui.com/easyui/datagrid-detailview.js"></script>
    <script type="text/javascript">
        var conf = {
            options: {
                fitColumns: true,
                showHeader: false,
                columns: [[
                    {field:'group',width:100}
                ]],
                data: [
                    {group:'General Ledger'}
                ]
            },
            subgrid: {
                options: {
                    fitColumns: true,
                    showHeader: false,
                    scrollbarSize: 0,
                    columns: [[
                        {field:'header',width:100}
                    ]],
                    data: [
                        {header:'Accounts'},
                        {header:'Journals'}
                    ]
                },
                subgrid: {
                    options: {
                        fitColumns: true,
                        showHeader: false,
                        scrollbarSize: 0,
                        foreignField: 'header',
                        columns: [[
                            {field:'item',width:100}
                        ]],
                        data: [
                            {item:'View Accounts',header:'Accounts',width:100},
                            {item:'Add Accounts',header:'Accounts',width:100},
                            {item:'Edit Accounts',header:'Accounts',width:100},
                            {item:'Disable Accounts',header:'Accounts',width:100},
                            {item:'View Journals',header:'Journals',width:100},
                            {item:'Add Journals',header:'Journals',width:100}
                        ],
                        loadFilter: function(data){
                            var opts = $(this).datagrid('options');
                            var fvalue = opts.queryParams[opts.foreignField];
                            var rows = [];
                            for(var i=0; i<data.length; i++){
                                if (data[i][opts.foreignField] == fvalue) {
                                    rows.push(data[i])
                                }
                            }
                            return rows;
                        }
                    }
                }
            }
        }
        $(function(){
            $('#dg').datagrid({
                width: 300,
                height: 500
            }).datagrid('subgrid', conf)
        })
    </script>
</head>
<body>
   
    <table id='dg'></table>
</body>
</html>
Logged
thecyberzone
Full Member
***
Posts: 176



View Profile Email
« Reply #2 on: September 17, 2021, 09:46:17 AM »

There is no documentation found about Datagrid subgrid method. Please include it in the documentation.
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #3 on: September 17, 2021, 06:48:48 PM »

The 'subgrid' method is extended in DataGrid View Extension.

https://www.jeasyui.com/extension/datagridview.php
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!