Erik
Erik

Reputation: 12120

dojox.grid.DataGrid Custom Cell?

who knows a way to create a custom cell fora dojox.grid.DataGrid? I of course could use the get and formatter properties of the layout, but this is not a really reusable solution!

Thanks for your input!

heinrich

Upvotes: 1

Views: 2986

Answers (2)

Kryptic Coder
Kryptic Coder

Reputation: 622

You can try an indirect way to add a dojo widget to a grid cell

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

2) Then in the get/formatter function try something like

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!

Upvotes: 1

Manu
Manu

Reputation: 4123

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"
  • set 'singleClickEdit'= "true" and
  • set cellType variable. 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.

Upvotes: 2

Related Questions