我的目标是创建一个dGrid,其中每列都有一个标签和一个名为comments的标签旁边的按钮。
仅当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
);
答案 0 :(得分:2)
使用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;
}