I know this thread is old, but I thought I'd reply with a solution in case anyone is still scratching their head on this one.
In order to dynamically size the columns based on the length of the header titles you'll need to put the string in an empty (invisible) span, measure the span, add some margin value and then use that as your column width. I used the ColumnResizer mixin so the sizing happens through the resizeColumnWidth() method. the dojoObject.forIn() method comes from dojox/lang/functional/object as a way to iterate over an associative array.
fitColumns: function (grid) {
dojoObject.forIn(grid.columns, function (item) {
var node = domConstruct.toDom('<span style="position:absolute;visibility:hidden">' + item.label + '</span>');
domConstruct.place(node, grid.id);
var p = domGeom.position(node);
domConstruct.destroy(node);
grid.resizeColumnWidth(item.id, p.w + 8);
});
}