Dojo DataGrid(DGrid)添加复选框列 [英] Dojo DataGrid (DGrid) Adding checkbox column
问题描述
我正在使用 Dojo Dgrid,但是我试图添加一个复选框列,但我不确定该方法。
I am using Dojo Dgrid however i am trying to add a checkbox column however i am not sure of the approach.
我一直在看的大部分教程都遵循不同的代码结构,我无法创建复选框列。我想创建一个复选框列来选择行
Most of the tutorials i have been looking at follow a different code structure and i am unable to create the check box column. I would like to create a checkbox column to select rows
代码(这里也是一个 Fiddle 我的代码)
Code (Here is also a Fiddle of my code)
require([
。 ......................
dojo / domReady!
require([
.......................
"dojo/domReady!"
], function(parser, declare, Grid, ColumnSet, Selection, selector,Keyboard, DijitRegistry){
parser.parse();
var data = [
{ first: "Tom", last: "Evans" },
{ first: "Sherry", last: "Young"},
{ first: "Bob", last: "William"}
];
var columns = [
[[
{editor({name: "CheckBox", field: "bool"}, "checkbox")},
{ field: "first", label: "First" },
{ field: "last", label: "Last" }]]
];
var CustomGrid = declare([Grid, ColumnSet, Selection, Keyboard, DijitRegistry]);
var grid = new CustomGrid ({
columnSets: columns ,
"class":"grid"
}, "grid");
grid.renderArray(data);
});
推荐答案
如果你想有一个列,选择行的目的,你应该设置你的目标在选择器
列插件,而不是编辑器
。 选择器
专门用于在每个单元格中复选框(或单选按钮)连接到 Selection
mixin 。
If you want to have a column with checkboxes for the purpose of selecting rows, you should set your sights on the selector
column plugin rather than editor
. selector
is specifically designed to render checkboxes (or radio buttons) in each cell that ties in to the Selection
mixin when checked.
这篇关于Dojo DataGrid(DGrid)添加复选框列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!