EasyUI Forum
November 05, 2025, 03:04:00 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: TreeGrid checkbox cell  (Read 8410 times)
Sano
Newbie
*
Posts: 1


View Profile
« on: April 04, 2017, 11:13:53 PM »

Hello
I'm trying to show data in TreeGrid and one field must look like a checkbox.
I found two similar solution for DataGrid and try to apply it for my situation:

#1: This solution doesn't work, cell value displayed as string (true, false)
Code:
        let data = $.ajax({
            type: "POST",
            url: "/path/to data/",
            dataType: "json",
            async: false,
        }).responseJSON;


        $('#tg').treegrid({
            data: data,
            idField: 'id',
            treeField: 'name',
            height: '100%',
            columns: [[
                {title: 'Name', field: 'name', width: 240},
                {
                    title: 'Value', field: 'value', width: 50, editor: {
                    type: 'checkbox',
                    options: {
                        on: true,
                        off: false
                    }
                }
                }
            ]],
        });
    }

#2: This works, i send checked data to server-side JSON.stringify(rows), but value parameter always in false.
Code:
        
            let data = $.ajax({
            type: "POST",
            url: "/path/to data/",
            dataType: "json",
            async: false,
        }).responseJSON;


        $('#tg').treegrid({
            data: data,
            idField: 'id',
            treeField: 'name',
            height: '100%',
            columns: [[
                {title: 'Name', field: 'name', width: 240},
                {
                    title: 'Value', field: 'value', width: 50, formatter: function (value, row, index) {
                    if (value) {
                        return '<input type="checkbox" checked>';
                    }
                    else {
                        return '<input type="checkbox" >';
                    }
                }
                },
            ]],
        });
    }

And second question. How to check|uncheck needed cells in JS programmatically.

Thank you, i hope there is a simple soluthion for this  Smiley
Logged
jarry
Administrator
Hero Member
*****
Posts: 2300


View Profile Email
« Reply #1 on: April 07, 2017, 06:32:22 PM »

The 'checkbox' is the built-in property in treegrid component. Please look at this example https://www.jeasyui.com/demo/main/index.php?plugin=TreeGrid&theme=default&dir=ltr&pitem=Cascade%20CheckBox
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!