在dojo内通过编程方式在网格中添加单选按钮

问题描述 投票:-1回答:1

我想为每行添加单选按钮。我正在搜索一些在线dojo示例,以编程方式添加单选按钮,但找不到解决方案。请提出每次添加新行时如何在每行的column1之前添加单选按钮的建议。以下是小提琴:http://jsfiddle.net/Q9GYv/59/

示例代码:

    /*create a new grid*/
    var grid = new DataGrid({
        id: 'grid',
        store: store,
        structure: layout,
        rowSelector: '20px'
    });

    /*append the new grid to the div*/
    grid.placeAt("gridDiv");

    /*Call startup() to render the grid*/
    grid.startup();

    var id = 2;

    var button = new Button({
        onClick: function () {
            console.log(arguments);
            store.newItem({
                id: id,
                col2: "col2-" + id,
                col3: "col3-" + id,
                col4: "col4-" + id
            });
            id++;
        }
    }, "addRow");
});
javascript jquery html dojo
1个回答
1
投票

有几种方法可以做到这一点,但是我能想到的最简单的方法就是更改布局,然后在布局中添加一个单选按钮(dojox / grid / _RadioSelector)。

类似

var layout = [
    { type: "dojox.grid._RadioSelector"},
    [{
        'name': 'Column 1',
            'field': 'id',
            'width': '100px'
    }, {
        'name': 'Column 2',
            'field': 'col2',
            'width': '100px'
    }, {
        'name': 'Column 3',
            'field': 'col3',
            'width': '200px'
    }, {
        'name': 'Column 4',
            'field': 'col4',
            'width': '150px'
    }]
];

我已经更新了您的小提琴here,向您展示了它的完成方式。

© www.soinside.com 2019 - 2024. All rights reserved.