I'm trying to use MVCContrib grid together with KnockoutJS. To do this I have to specify data binding in tbody, e.g. <tbody data-bind="foreach: people">. I can't find the way how to do this.
@Html.Grid(Model).Attributes() applies my binding to <table> tag. Is there a way to set the tbody attribute?
The short answer is no, there is no way to set attributes on the
tbodywith the current implementation.But you can implement this functionality by yourself:
You just need to implement your own version of the
RenderBodyStartmothod from theGridRendererclass.There is alredy an implementation of the
GridRenderercalledHtmlTableGridRendererwhat you can build on:And in your view instead of calling
Render()you can use theRenderUsingmethod where you can specify your custom renderer:And the generated html will look something like this:
You should note this is just a quick and dirty solution to show what is possible and there are more extension points what you can use to make the attribute passing more nicer.