EasyUI Forum
December 21, 2025, 07:23:41 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
  Home Help Search Login Register  
  Show Posts
Pages: [1]
1  General Category / EasyUI for jQuery / TreeGrid checkbox cell 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
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!