I've just committed a change that should make this a bit easier (you'll need to build from the latest source from svn - revision 958).
Now, you can do this:
public class MyGridRenderer<T> : HtmlTableGridRenderer<T> where T : class
{
protected override void RenderItems() {
if(IsDataSourceEmpty())
{
RenderEmpty();
return;
}
base.RenderItems();
}
protected override void RenderEmpty() {
int numberOfColumns = GridModel.Columns.Count;
RenderText("<tbody>");
RenderText(string.Format("<tr><td colspan='{0}'>{1}</td></tr>", numberOfColumns, GridModel.EmptyText));
RenderText("</tbody>");
}
protected override bool ShouldRenderHeader() {
return true;
}
}
Previously, the check for whether the header should be rendered was inside the RenderHeader method, meaning that if you wanted to change this behaviour then you had to re-implement all of RenderHeader, but i've now moved it into a ShouldRenderHeader method.
Note that you also have to override RenderItems and explicitly check for whether the datasource is empty. If you don't do this, it will just render the header but with no rows.
Jeremy