This project is read-only.

How to set id to the grid

May 19, 2011 at 5:44 AM

Hi all,


The extension @Html.ThemedDataGridFor doesn't have any mean to set the id for the table. I know i can use Jquery but I'd prefer to have it included in the extension.


Best regards,

Nam Vo.

May 19, 2011 at 8:48 PM

The id is not included in the @Html.ThemedDataGridFor helper because that method just call a partial view containing an implementation of the grid specific for a theme....Some themes might contaion a table other might contain an <ul><li> list and some other simply a dive for each data item with no root father at all. Thus an id passed to that function makes no sense.

However you may compute and id starting from the lambda expression used to call the helper as usual in Mvc.

To do this you may modify the example theme I included in the RazorCompleteExample file. Specifically go to the DisplayHeader Razor helper, and modify the table tag:

<Table id = '@htmlHelper.ViewData.TemplateInfo.GetFullHtmlFieldId(options.ToShow)'>

You may also add some postfix such as "_Root" or "_Table" if you want to give names to various html elements.

Anyway if you need the id to "act" someway on the table from javascript consider that if you at a later time change theme, the javascript code might be inadequate to the new theme, so the javascript code need to be included in a file specific for the theme. I advice to read carefully the documentation on the themes: