Specify the width for each column individually

395 views
Skip to first unread message

AndreNascentes

unread,
Jun 9, 2009, 8:58:06 AM6/9/09
to mvccontrib-discuss
Hi all!

I'm using "Attributes(style => "width:90%")" after the columns
declaration to specify the total width of the grid, but I want to
manage the width of the columns individually.

I've put "Attributes(style => "width:90%")" after each column, but it
doesn't work fine.

Is there a way to specify the width for each column individually?

Thanks!

Jeremy Skinner

unread,
Jun 9, 2009, 9:07:57 AM6/9/09
to mvccontri...@googlegroups.com
You should be able to use the Attributes method on the column definition like this:

column.For(x => x.Name).Attributes(style => "width: 90%");

...and this works fine for me. What problems do you encounter when you try to do this?

Jeremy

2009/6/9 AndreNascentes <andrena...@gmail.com>

André Nascentes

unread,
Jun 9, 2009, 12:41:54 PM6/9/09
to mvccontri...@googlegroups.com
When I use "Attributes" in a aspx page, it works fine. But when I have a grid in a ascx page redered inside a thickbox, it doesn't works.

2009/6/9 Jeremy Skinner <jer...@jeremyskinner.co.uk>



--
André Nascentes

Jeremy Skinner

unread,
Jun 9, 2009, 1:10:08 PM6/9/09
to mvccontri...@googlegroups.com
Could you elaborate on what you mean when you say "it doesn't work". Do you get an error? If so, what is the message? Is the style element not being output correctly? 

I just put together a quick test using thickbox and the default css and I cannot see any problems.

Jeremy



2009/6/9 André Nascentes <andrena...@gmail.com>

André Nascentes

unread,
Jun 9, 2009, 1:33:12 PM6/9/09
to mvccontri...@googlegroups.com
No matter the value I set to the width property, the width still the same.

I'll verify my css, maybe could be a conflict between the thickbox css and the grid css.

Thanks a lot!



2009/6/9 Jeremy Skinner <jer...@jeremyskinner.co.uk>



--
André Nascentes

Jeremy Skinner

unread,
Jun 9, 2009, 1:37:47 PM6/9/09
to mvccontri...@googlegroups.com
This is what it sounds like to me. Calling Attributes(style => "width: 90%") on a column will always cause the style attribute to be rendered for the <tr>. If this isn't showing up correctly in the browser then I expect it to be css-related rather than a problem with the grid. One way to be sure would be to temporarily remove the grid and use an HTML table with the same attributes instead.

André Nascentes

unread,
Jun 10, 2009, 7:20:05 AM6/10/09
to mvccontri...@googlegroups.com
Hey Jeremy!

It was a fieldset messing the things up!
Thanks for the attention and patience!

André


2009/6/9 Jeremy Skinner <jer...@jeremyskinner.co.uk>



--
André Nascentes
Reply all
Reply to author
Forward
0 new messages