簡體   English   中英

在dojo內以編程方式添加單選按鈕以增強網格

[英]adding radiobutton inside dojo enhanced grid programmatically

我想為每一行添加單選按鈕。 我正在搜索一些在線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");
});

有幾種方法可以做到這一點,但是我能想到的最簡單的方法就是更改布局,然后在布局中添加一個單選按鈕(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'
    }]
];

我在這里更新了您的小提琴,向您展示了它是如何完成的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM