Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Senior Coder nikos101's Avatar
    Join Date
    Dec 2006
    Location
    London
    Posts
    1,008
    Thanks
    59
    Thanked 10 Times in 10 Posts

    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


  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Check the usage of col tag at http://htmldog.com/reference/htmltags/col/
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,918
    Thanks
    6
    Thanked 1,040 Times in 1,013 Posts
    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.

  • #4
    Senior Coder nikos101's Avatar
    Join Date
    Dec 2006
    Location
    London
    Posts
    1,008
    Thanks
    59
    Thanked 10 Times in 10 Posts
    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 12:08 PM.


  • #5
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,918
    Thanks
    6
    Thanked 1,040 Times in 1,013 Posts
    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 */

  • Users who have thanked VIPStephan for this post:

    nikos101 (05-09-2012)

  • #6
    Senior Coder nikos101's Avatar
    Join Date
    Dec 2006
    Location
    London
    Posts
    1,008
    Thanks
    59
    Thanked 10 Times in 10 Posts
    Cool thats helpful!!



  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •