简体   繁体   English

dojox.grid.DataGrid自定义单元格?

[英]dojox.grid.DataGrid Custom Cell?

who knows a way to create a custom cell fora dojox.grid.DataGrid ? 谁知道为dojox.grid.DataGrid创建自定义单元的方法? I of course could use the get and formatter properties of the layout, but this is not a really reusable solution! 我当然可以使用布局的get和formatter属性,但这不是一个真正可重用的解决方案!

Thanks for your input! 感谢您的输入!

heinrich 海因里希

What do you mean by custom cell? 自定义单元是什么意思?

Do you want to use check box or textbox instead of text? 是否要使用复选框或文本框代替文本? or 要么

Do you want to show images instead of text? 您要显示图像而不是文本吗?

In the first case 在第一种情况下

  • give 'editable'="true" 给'editable'=“ true”
  • set 'singleClickEdit'= "true" and 设置'singleClickEdit'=“ true”并
  • set cellType variable. 设置cellType变量。 You can extend the default editor class and make your own editor class. 您可以扩展默认编辑器类并创建自己的编辑器类。

In the second case you can use the formatter function. 在第二种情况下,您可以使用格式化程序功能。

It is better to use the existing functions and classes. 最好使用现有的函数和类。 Extending will make the grid slower. 扩展将使网格变慢。

You can try an indirect way to add a dojo widget to a grid cell 您可以尝试使用间接方式将dojo小部件添加到网格单元

1) Set escapeHTMLInData to false for the dojox.grid.DataGrid 1)设置escapeHTMLInDatafalsedojox.grid.DataGrid

2) Then in the get/formatter function try something like 2)然后在get / formatter函数中尝试类似

function formatterFn() {
    var buttonToReturn = dijit.form.Button({
        /* Button attributes */
    }
    var div = document.createElement("div");
    div.appendChild(buttonToReturn.domNode);
    return div.innerHTML;
    // You can leave the div orphan
}

You can conditionally return different widgets to suit your needs 您可以有条件地返回不同的小部件以适合您的需求

Hope it helps! 希望能帮助到你!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM