【问题标题】:Is there any way to add edit/delete button in each row for DHTMLX grid?有没有办法在 DHTMLX 网格的每一行中添加编辑/删除按钮?
【发布时间】:2014-07-02 14:15:38
【问题描述】:

我正在处理 DHTMLX 网格,我需要在每一行中添加编辑/删除按钮,有什么方法可以做到。我用谷歌搜索了它,我能够找到关于复选框和链接。

任何帮助将不胜感激。

【问题讨论】:

    标签: javascript jquery css json dhtmlx


    【解决方案1】:

    您可以使用任何所需的 html 内容创建自定义列类型。 例如,以下代码将创建一个 eXcell,它将单元格值呈现为带有标签的按钮:

       function eXcell_button(cell){ //the eXcell name is defined here
            if (cell){                // the default pattern, just copy it
                this.cell = cell;
                this.grid = this.cell.parentNode.grid;
            }
            this.edit = function(){}  //read-only cell doesn't have edit method
            this.isDisabled = function(){ return true; } // the cell is read-only, so it's always in the disabled state
            this.setValue=function(val){
                this.setCValue("<input type='button' value='"+val+"'>",val);                                      
            }
        }
        eXcell_button.prototype = new eXcell; // nests all other methods from the base class
    

    之后您只需要在网格中设置列类型:

    grid.setColTypes("button,...");
    

    在这里您可以找到包含各种示例的详细教程: http://docs.dhtmlx.com/grid__columns_types.html#customeditors

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-09-25
      • 2015-03-04
      • 1970-01-01
      • 2012-06-09
      • 1970-01-01
      • 1970-01-01
      • 2021-02-08
      • 1970-01-01
      相关资源
      最近更新 更多