the_drow
the_drow

Reputation: 19181

How to create a new widget for dojox.grid.cells.dijit?

I am trying to create a button widget for dojox.grid.
My problems are:
1) The button is only shown when I double click the grid.
2) I can't figure out how to set attributes through declarative markup. It seems that the markupFactory function is responsible for it but it doesn't set the widget's label. The following code demonstrates what I've got so far:

dojo.require("dojox.grid.DataGrid");
dojo.require("dojo.data.ItemFileWriteStore");
dojo.require("dijit.form.Button");
dojo.require("dojox.grid.cells.dijit");
dojo.require("dojo.parser");
dojo.declare("dojox.grid.cells.Button", dojox.grid.cells._Widget, {
    widgetClass: dijit.form.Button,
    alwaysEditing: true,
    constructor: function(inCell)
    {
    this.inherited(arguments);
    this.widget = new dijit.form.Button;
    },
    setValue: function(inRowIndex, inValue){
    if (this.widget) {
                this.widget.attr('value', inValue);
            }
            else {
                this.inherited(arguments);
            }
    }
});

dojox.grid.cells.Button.markupFactory = function(node, cell)
{
    dojox.grid.cells._Widget.markupFactory(node, cell);
}

Upvotes: 4

Views: 2242

Answers (1)

case nelson
case nelson

Reputation: 3657

For 1) The button is only shown when I double click the grid.

Set singleClickEdit: true in the Grid parameters

this.grid = new dojox.grid.DataGrid({
    singleClickEdit: true,
    structure: view1,
}, tmp);

Upvotes: 2

Related Questions