Link to home
Start Free TrialLog in
Avatar of Charles Sugden
Charles SugdenFlag for United States of America

asked on

Cant control Data widths within TD elements

I have data that I am displaying within a table.
The table has 5 columns with a header.
Each element has a CSS class assigned to it.

The objective is to keep the column widths fixed over any requeries using a filter on the same page.

The observed behaviour is that the column widths do not respect the min/max width of the CSS properties and shrink to the size of the largest data item.

I have tried wrapping the data with DIVs within the TDs but that is no help. See code attached
SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Charles Sugden

ASKER

Code file is now attached...Sorry Dave!
htmlTableProblem.txt
Ok, you need to show me the code seen in the "View Source" of your browser.  It is not possible to tell what your server side code is going to generate.  But it Always ends up as HTML in a browser and that's where we have to identify the problem.
I have enclosed the html source from the first page and the source from the second page after a filter expression was applied.

The html was optimized a bit since the initial code but the problem remains
htmlFirstPass.htm
htmlSecondPass.htm
I thought that would help but not nearly enough.  You have too many scripts to load (that I don't have) to be able to display that on my computer.  And I would guess that it is supposed to be 'responsive' also which complicates the problem.  If this is available online, then maybe a link would let us see what's going on.
I am enclosing a screen shot of what I see. I see no visible reason in the HTML for this to occur. I figure it is a peculiarity of oneof the tags.

This app is generetaed using a MVC4 demo. The master page is almost verbatim with what you would find on line. I have also included that here
FirstPass.GIF
SecondPass.GIF
Layout.txt
I don't see an actual problem there.  The most likely difference is that in the FirstPass image, there are probably longer strings in cells that are not visible in that view.  Scroll down and you will probably find them.  In SecondPass, there would be no strings longer than what are seen on the screen.  What you are seeing is normal behavior for <td>s in tables that have no specific width.

If you do something like this, all the columns will stay put... as long as none of the data is wider than the column.  You can see that I put a specific width in each of the <th> columns.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>Untitled</title>
</head>
<body>
<table class="indextable" id="example" border="1">

    <tr>
        <th width="180px">
            Name
        </th>
        <th width="200px">
            Company Name
        </th>
        <th width="240px">
            E-Mail
        </th>
        <th width="180px">
            Phone
        </th>
        <th width="180px">
            Actions
        </th>
    </tr>

        <tr>
        <td class="custindextd">
            Ms. Catherine R. Abel 
        </td>
        <td class="custindextd">
            Professional Sales and Service
        </td>
        <td class="custindextd">
            catherine0@adventure-works.com
        </td>
        <td class="custindextd">
            747-555-0171
        </td>
        <td class="custindextd"> 
        

            <a href="/Customer/Edit/29485">
            <img alt = "Edit" src="/Images/edit.gif"  class="Icon" title="Edit"/>
            </a> 
            <a href="/Customer/Details/29485">
            <img alt = "Detail" src="/Images/details.gif" class="Icon" title="Info"/>
            </a>            
            <a href="/Customer/Delete/29485">
            <img alt = "Delete" src="/Images/del.gif"  class="Icon" title="Delete"/>
            </a> 
            <a href="/Customer/Sales/29485">
            <img alt = "Sales" src="/Images/information.gif"  class="Icon" title="Sales"/>
            </a> 
         </td>
    </tr>
        <tr>
        <td class="custindextd">
            Mr. Christopher R. Beck Jr.
        </td>
        <td class="custindextd">
            Bulk Discount Store
        </td>
        <td class="custindextd">
            christopher1@adventure-works.com
        </td>
        <td class="custindextd">
            1 (11) 500 555-0132
        </td>
        <td class="custindextd"> 
        

            <a href="/Customer/Edit/29546">
            <img alt = "Edit" src="/Images/edit.gif"  class="Icon" title="Edit"/>
            </a> 
            <a href="/Customer/Details/29546">
            <img alt = "Detail" src="/Images/details.gif" class="Icon" title="Info"/>
            </a>            
            <a href="/Customer/Delete/29546">
            <img alt = "Delete" src="/Images/del.gif"  class="Icon" title="Delete"/>
            </a> 
            <a href="/Customer/Sales/29546">
            <img alt = "Sales" src="/Images/information.gif"  class="Icon" title="Sales"/>
            </a> 
         </td>
    </tr>
        <tr>
        <td class="custindextd">
            Mr. Donald L. Blanton 
        </td>
        <td class="custindextd">
            Coalition Bike Company
        </td>
        <td class="custindextd">
            donald0@adventure-works.com
        </td>
        <td class="custindextd">
            357-555-0161
        </td>
        <td class="custindextd"> 
        

            <a href="/Customer/Edit/29568">
            <img alt = "Edit" src="/Images/edit.gif"  class="Icon" title="Edit"/>
            </a> 
            <a href="/Customer/Details/29568">
            <img alt = "Detail" src="/Images/details.gif" class="Icon" title="Info"/>
            </a>            
            <a href="/Customer/Delete/29568">
            <img alt = "Delete" src="/Images/del.gif"  class="Icon" title="Delete"/>
            </a> 
            <a href="/Customer/Sales/29568">
            <img alt = "Sales" src="/Images/information.gif"  class="Icon" title="Sales"/>
            </a> 
         </td>
    </tr>
        <tr>
        <td class="custindextd">
            Mr. Cory K. Booth 
        </td>
        <td class="custindextd">
            Remarkable Bike Store
        </td>
        <td class="custindextd">
            cory0@adventure-works.com
        </td>
        <td class="custindextd">
            121-555-0157
        </td>
        <td class="custindextd"> 
        

            <a href="/Customer/Edit/29531">
            <img alt = "Edit" src="/Images/edit.gif"  class="Icon" title="Edit"/>
            </a> 
            <a href="/Customer/Details/29531">
            <img alt = "Detail" src="/Images/details.gif" class="Icon" title="Info"/>
            </a>            
            <a href="/Customer/Delete/29531">
            <img alt = "Delete" src="/Images/del.gif"  class="Icon" title="Delete"/>
            </a> 
            <a href="/Customer/Sales/29531">
            <img alt = "Sales" src="/Images/information.gif"  class="Icon" title="Sales"/>
            </a> 
         </td>
    </tr>
		</table>
</body>
</html>

Open in new window

perhaps I havent explained this properly. I would like the style info to truncate the output of the longer-than-width of the column.

I tried your example also by drastically shortening the width and it only wrapped. I also tried style="width:20px;overflow:hidden;    min-width:20px;    max-width:20px; white-space:nowrap;" which i though should have worked but that also wrapped.

Is there any solution using html or do I have to adjust the data source?
I would have thought that would work too but it clearly doesn't.  I don't know at the moment.
I am going to cancel this question and perhaps with time come closer to the answer.
Thank you for your help
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This was clearly a bug in my own code and perhaps the attachments were redacted not to show the spurious character