1

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

2 Answers 2

2

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.

2
  • I would like to create a cell that does custom formatting of the values, e.g. a cell that displays a button!
    – Erik
    Commented Dec 8, 2010 at 9:16
  • Check the file dojo-release-1.5.0-src/dojox/grid/cells/dijit.js. This contains some editors if none of these matches your requirement extend the close matching one. Don't forget to write the 'markupFactory' function. Without that function it will not work.
    – Manu
    Commented Dec 9, 2010 at 4:00
1

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!

1
  • 1
    Since 1.4 you don't need escapeHTMLInData any more. If the formatter returns a widget, it is parsed.
    – Erik
    Commented Dec 9, 2010 at 13:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.