Dojo DataGrid(DGrid)添加复选框列 [英] Dojo DataGrid (DGrid) Adding checkbox column

查看:305
本文介绍了Dojo DataGrid(DGrid)添加复选框列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 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.

请参阅 wiki中的文档,以及选择器测试页

这篇关于Dojo DataGrid(DGrid)添加复选框列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆