Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-04-2012, 10:05 AM   PM User | #1
nikos101
Senior Coder

 
nikos101's Avatar
 
Join Date: Dec 2006
Location: London
Posts: 1,004
Thanks: 58
Thanked 10 Times in 10 Posts
nikos101 is an unknown quantity at this point
Question Trouble with col width

For some reason the width is ignored

Code:
 <table>
   <col width="200" />
   <tbody>
@foreach (var item in Model.ComplaintsAuditTrail) {
    <tr>
        <td >
            @Html.DisplayFor(modelItem => item.complaint)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.dateCreated)
        </td>

   +20 more td per row  ..etc
__________________

nikos101 is offline   Reply With Quote
Old 05-04-2012, 10:15 AM   PM User | #2
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,678
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Check the usage of col tag at http://htmldog.com/reference/htmltags/col/
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 05-04-2012, 10:24 AM   PM User | #3
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,587
Thanks: 5
Thanked 864 Times in 841 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
Yeah, you have to address all columns in the table. That means you have to do the math, just as with colspan and rowspan. If you want all columns to be the same width then use the span attribute with the number of columns as value.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 05-08-2012, 08:29 AM   PM User | #4
nikos101
Senior Coder

 
nikos101's Avatar
 
Join Date: Dec 2006
Location: London
Posts: 1,004
Thanks: 58
Thanked 10 Times in 10 Posts
nikos101 is an unknown quantity at this point
I gave them all widths like so but its unreliable

Code:
<div id="scrollable" >
<table>
   <col width="200" />
   <col width="70" />
   <col width="70" />
   <col width="70" />
   <col width="70" />
   <col width="70" />
   <col width="70" />
   <col width="70" />
   <col width="70" />
   <col width="70" />
   <col width="70" />
   <col width="70" />
   <col width="70" />
   <col width="70" />
   <col width="70" />
   <col width="70" />
   <col width="70" />
   <col width="70" />
   <col width="70" />
   <col width="70" />
   <col width="70" />
   <col width="70" />
   <col width="70" />
   <col width="70" />
   <col width="70" />
   <col width="70" />
   <col width="70" />
   <col width="70" />
   <col width="70" />
   <tbody>
maybe i should just use telerick.
__________________


Last edited by nikos101; 05-08-2012 at 11:08 AM..
nikos101 is offline   Reply With Quote
Old 05-09-2012, 12:24 AM   PM User | #5
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,587
Thanks: 5
Thanked 864 Times in 841 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
How is it unreliable?
And you can simplify this a lot by writing:
Code:
<table>
  <col class="col1" />
  <col class="col2" span="20" /> <!-- change the number to the number of columns to which the same styles should apply -->
  <tbody>
  …
  …
As far as I know the width attribute isn’t actually deprecated in the current standards specification (HTML 4.01/XHTML 1) but it’s not present in the HTML 5 working draft, and in my opinion it’s good practice to separate styling from the structure so it’s better to use CSS for applying the width to the columns, for which I have added the classes.
Code:
.col1 {width: 200px;}
.col2 {width: 70px;} /* should apply to all individual columns that are defined by the value of the span attribute */
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Users who have thanked VIPStephan for this post:
nikos101 (05-09-2012)
Old 05-09-2012, 10:48 AM   PM User | #6
nikos101
Senior Coder

 
nikos101's Avatar
 
Join Date: Dec 2006
Location: London
Posts: 1,004
Thanks: 58
Thanked 10 Times in 10 Posts
nikos101 is an unknown quantity at this point
Cool thats helpful!!
__________________

nikos101 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:10 AM.


Advertisement
Log in to turn off these ads.