I don't know if you copy and pasted that code right from your tool of
choice, but you've got single and double quotes mixed up at

<div id='table_container">
and
<th id="col_1" class='ColumnHeader">

use single quotes or double quotes, but not one of each, that will
cause major issues

also, your code for function "Grid_Colunns_Resize" is nothing like
what i posted, don't you want the tables to have the same width per
column?  if that's the case, you have to check *both* tables to see
which one is wider

here's updated (and working) code with your table structure

http://paste.pocoo.org/show/106700/



On Mar 6, 3:03 am, Alain Roger <raf.n...@gmail.com> wrote:
> On Thu, Mar 5, 2009 at 9:41 PM, MorningZ <morni...@gmail.com> wrote:
>
> > Can you post (preferably onhttp://paste.pocoo.org/) what:
> > 1) What both tables look like? (as previously mentioned, your screen
> > shot only shows one table, that doesn't help)
> > 2) how you are assigning the variable "$slave_table"
>
> > Seeing both those will help solve the issue
>
> > ok, for example, here is my html code snippet:
>
> <div id='table_container">
>     <table id="frm_table">
>         <thead>
>             <tr>
>                 <th id="col_1" class='ColumnHeader">ID</th>
>                 <th id="col_2" class='ColumnHeader">Language</th>
>                 <th id="col_3" class='ColumnHeader">Dexcription</th>
>             </tr>
>         </thead>
>     </table>
> </div>
> <div id="data_framework">
>     <table id="data_grid">
>         <tbody id="tabbody">
>             <tr>
>                 <td>1</td>
>                 <td>ENG</td>
>                 <td>English</td>
>             </tr>
>             <tr>
>                 <td>2</td>
>                 <td>FRE</td>
>                 <td>French</td>
>             </tr>
>         </tbody>
>     </table>
> </div>
>
> in my jQuery code if i use :
> $slave_table.find("tbody").each(function(i){..});
> it works but if i add the tr as following:
> $slave_table.find("tbody tr").each(function(i){..});
> or
> $slave_table.find("tbody").find("tr").each(function(i){..});
> it does not work
>
> those code lines are in a function defined as following:
> function Grid_Colunns_Resize($master_table, $slave_table)
> {
>  var MaxWidths = {};
>  var $th;
>
>  // both table exist and are only found once into document
>  if($master_table.length == 1 && $slave_table.length == 1)
>  {
>   $master_table.find("thead tr").find("th.ColumnHeader").each(function(i)
>   {
>     if (MaxWidths[i] == null || ($(this).width() > MaxWidths[i]))
>     {
>        MaxWidths[i] = $(this).width() || 0;
>     }
>   }
>
> });
>
> $slave_table.find("tbody tr").each(function(i)
> {
>  alert("tbody tr");
>
> });
>
> i call this function as following:
> Grid_Colunns_Resize($("#frm_table"), $("#data_grid"));
>
> is it clearer ?
>
> A.

Reply via email to