If you define the columns of a grid in markup using table, tr, and th tags, should it be possible for the constraint to be specified on the th tag? The formatter seems to be recognized, but I haven't had any luck with the constraint. For example,
I'm still not sure I understand. Is the method you're saying different than the one used in the example I provided? I tried this using dojo 1.6.0 against multiple browsers and this.constraint was always undefined in the formatter. Could you perhaps point me to a small example of what the correct format is?
I spent some more time looking at this and believe I have a better idea of what's going on. This would have been more obvious if I had more experience with Dojo, but right now the markup parser assumes constraints are tied to editors. The code that actually parses the constraint attr is in the markupFactory on dojox.grid.cells._Widget. The markupFactory on dojox.grid.cells._Base doesn't have code to parse the constraint attr. The example in the original post failed because I had not defined a specific editor for the cell. Even specifying editable="true" is not enough; the cellType attr must be defined to something.
I do consider this a bug / feature request. It seems like a valid use case to have a formatter that renders values depending on the row AND column. The formatter function only receives the value and rowIndex. The only way to make this happen based on what I know now is to specify data on the constraint. Moreover, when creating a grid programmatically, it is possible to have a formatter and constraint without an editor. It seems like there should be consistency between the features of the grid you can access from both methods of creation.
My solution was to add the parsing code to the markupFactory in dojox.grid.cells._Base -
var constraint = d.trim(d.attr(node, "constraint")||"");
cellDef.constraint = d.fromJson(constraint);
Would it be possible to see this in a future version of Dojo? What's the protocol for submitting tickets / patches?