【问题标题】:Dojo DGrid- how do I add in a button to a column's label?Dojo DGrid-如何将按钮添加到列的标签?
【发布时间】:2014-03-13 16:03:35
【问题描述】:

我的目标是创建一个 dGrid,其中每列都有一个标签,并且在标签旁边有一个名为 cmets 的按钮。

仅当 slot_header != "" 时,我们才会将列全部隐藏起来。当我通过它“”时,我有隐藏工作。只是当我传递 header = "HELLO" 时,列的标签变为:

“HELLO[Widget dijit.form.Button, dijit_form_Button_19]” 目标是“HELLO”CLICKABLEBUTTON

我正在使用 PHP 来实例化网格,然后在 renderCell 中使用 lang.hitch 来构建进入 domNode 的内容,任何帮助将不胜感激

   $singleStudentDetail = array(
    array('field' => 'line_nbr',     'label' =>'Line',              'properties' => array('width' => $width)),
    array('field' => 'skill_desc',     'label' =>'Skill',               'properties' => array('width' => $width)),
    array('field' => 'display_slot_01', 'label' => 'Notes',
                'properties' => array('width' => 55, 'sortable' => 'false', 'renderCell' =>
                'lang.hitch(this,function(object,value,node,options){

                            node.innerHTML = object["grades_01"];

                        var myButton = new Button({
                                            label: "Click me!",
                                            onClick: function(){
                                                // Do something:
                                                alert("THIS BUTTON WORKED");
                                            }
                                        });
                        if(object["slot_headings_01"] != "")
                        {
                            studentListDetailDGridVar.columns[3].label = object["slot_headings_01"] + myButton
                        }
                        else
                            studentListDetailDGridVar.columns[3].hidden = true;
})'
                )
        ));
$DgridParamsDetail = array(
    "columns"    => $singleStudentDetail,
    "gridVar"    => "studentListDetailDGridVar",
    "gridDiv"    => "studentListDetailDiv",
    "gridProperties"    =>  array("rowsPerPage" => 15),
    "render"        =>  true

);

【问题讨论】:

    标签: javascript php button dojo-dnd


    【解决方案1】:

    使用 renderCell 或 renderHeaderCell 时,您需要返回按钮的 domNode,而不是按钮小部件本身。

    下面是一个返回按钮的renderCell函数的javascript示例。

    renderCell: function(object, data, td, options) {
        return new Button({
            label: "Click me!",
            onClick: function() {
                console.log("THIS BUTTON WORKED!");
            }
        }).domNode;
    }
    

    【讨论】:

    • 你的意思是使用
    • 不,我的意思是在您的 renderCell 函数中,返回 button.domNode 而不是按钮对象。 renderCell 函数将返回给它的任何内容直接放在单元格中,因此返回一个小部件对象就是为您提供 [Widget ...] 但如果您返回 domNode ,它应该可以正常工作。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-27
    • 1970-01-01
    • 1970-01-01
    • 2010-12-15
    • 1970-01-01
    • 2013-09-06
    相关资源
    最近更新 更多