Grid with "using" statement.

Until now I have implemented the grid as an extention method of HtmlHelper. It works with a column builder, like the sample bellow:

Html.Grid(m => m.Id).Columns(column => {
            column.ForCommands();
            column.ForData(m => m.Id);
            column.ForData(m => m.Name);
            column.ForData(m => m.Email);
            column.ForData(m => m.Deleted);
}).Render()

But I'm thinking to change it to a class (named ModelViewGrid) that uses the "using" statement like the ModelViewForm class. It would look like that:

using(var grid = Html.Grid(m => m.Id/* grid global options */)) {
            grid.AddCommandColumn();
            grid.AddDataColumn(m => m.Id);
            grid.AddDataColumn(m => m.Name);
            grid.AddDataColumn(m => m.Email);
            grid.AddDataColumn(m => m.Deleted);
}

It doesn't look like a big difference but there is some changes mostly in the scope of the grid object and the how the data is available for each statement.
More about that later...

Last edited Jul 30, 2010 at 2:13 AM by AndreVianna, version 8

Comments

No comments yet.