Mottie / tablesorter

Github fork of Christian Bach's tablesorter plugin + awesomeness ~
https://mottie.github.io/tablesorter/docs/
2.6k stars 754 forks source link

Uncaught TypeError: Cannot call method 'format' of undefined #259

Closed karthickkumarganesh closed 11 years ago

karthickkumarganesh commented 11 years ago

am creating dynamic table with multiple tbody.

for($t=0;$t<count($tabs);$t++)
{  
    $conjava.='<script type="text/javascript">';
    $conjava.='alert("'.$tabs[$t]['email_user_ref_receiver'].'");';
    $conjava.='$(document).ready(function() {';

    $conjava.=' pagerOptionstab'.$tabs[$t]['email_user_ref_receiver'].' = {
                        container : $("#pagerrep'.$tabs[$t]['email_user_ref_receiver'].'"),
                        removeRows : false,
                        updateArrows : true
                    };
                    $(".tabvs_'.$tabs[$t]['email_user_ref_receiver'].'").tablesorter({
                        widthFixed : true,
                        cssInfoBlock : "tablesorter-no-sort",
                        widgets : ["zebra","stickyHeaders"],
                        headers : {
                            3 : {
                                sorter : false
                            },
                            4 : {
                                sorter : false
                            },
                            5 : {
                                sorter : false
                            }
                        }
                    }).tablesorterPager("pagerOptionstab'.$tabs[$t]['email_user_ref_receiver'].'");'; 
$conjava.='})';
$conjava.='</script>';
}
//$conjava.='{/literal}';
$smarty->assign('conjav', $conjava);

and also creating the initialization dynamically using above code .

<div id="tabs-{$foo1.email_user_ref_receiver}"> 

                    <div class="table_border" style="width:100%">

                      <table width="100%" cellpadding="0" cellspacing="0" 
                 class="tabvs_{$foo1.email_user_ref_receiver} tablesorter feed_table "  id="tbl_repeat">
                        <thead>
                          <tr >
                            <th class="first_class" width="20%">Tasks</th>
                            <th width="13%">Date Added</th>
                            <th width="8%">Status</th>
                            <th width="8%">Due on</th>
                            <th width="15%">Time Estimate</th>
                            <th width="20%">Options</th>
                          </tr>
                        </thead>

                        {if $arraycountyassignedtask{$foo1.email_user_ref_receiver} ne 0}
                        {assign var=setcounter value=0}
                        {foreach from=$task_{$foo1.email_user_ref_receiver} item=fook key=k }
                        {if $k eq 'threedaysold'}
                        {assign var=heading value='Less than 3 days old'}
                        {assign var=class value='user_head_Less_than_3_days_old'}
                        {/if}
                        {if $k eq 'twoweekoldless'}
                        {assign var=heading value='Less than 2 weeks old'}
                         {assign var=class value='user_head_Less_than_2_weeks_old'}
                        {/if}
                        {if $k eq 'threeweekoldless'}
                        {assign var=heading value='Less than 3 weeks old'}
                        {assign var=class value='user_head_Less_than_3_weeks_old'}
                        {/if}
                        {if $k eq 'onemonthless'}
                        {assign var=heading value='Less than 1 month old'}
                        {assign var=class value='user_head_Less_than_1_month_old'}

                        {/if}
                        {if $k eq 'onemonthmore'}
                        {assign var=heading value='More than 1 month old'}
                        {assign var=class value='user_head_More_than_1_month_old'}
                        {/if}
                       {if $task_{$foo1.email_user_ref_receiver}.$k|count ne 0}
                        <tbody class="tablesorter-no-sort {$class} " id="user_{$foo1.email_user_ref_receiver}">
    <tr id="0_0"><th colspan="7" align="left" style="padding-left:10px">{$heading}</th></tr></tbody>

                         <tbody id="{$class}" >
                         {foreach from=$fook item=foo }
                          <tr id="{$foo.priority}_{$foo.id}" {if $foo.task_status eq 1 }
                         class="NotStarted"
                            {elseif $foo.task_status eq 2}  class="InProgress" {elseif $foo.task_status eq 3}   class="ForReview" {/if}  >

                          <td width="20%"><a  href="#"  class="sticky" style="text-decoration:none; color:#000000;"  rel="hover?id={$foo.id}">{$foo.email_subject|ucfirst}</a></td>
                          <td width="13%">{$foo.email_time|date_format:'%Y-%m-%d'}</td>
                          <td width="8%"> {if $foo.task_status eq 1 }
                            Not Started
                            {elseif $foo.task_status eq 2}  In Progress {elseif $foo.task_status eq 3}  For Review {elseif $foo.task_status eq 4} Done {/if}</td>
                          <td width="8%" id="userduedate{$foo.id}">{if $foo.email_user_ref_sender eq $loggedUserId}
                            <input type="text" name="due_date_{$foo.id}" size="10" id="udue_date_{$foo.id}_{$foo.id}" class="datepicker1" value="{$foo.due_date}" onchange="updateDueDate(this.id)" />
                            {else} {if $foo.due_date eq ''} 0000-00-00{else} {$foo.due_date} {/if}{/if}</td>
                          <td width="15%" id="estimateuser_{$foo.id}"> {assign var=someVar value="@"|explode:$foo.time_estimate}
                            <select name="day" id="day_{$foo.id}_{$foo.id}">
                              <option value="0">D</option>

      {for $foo1=1 to 30}

                              <option value="{$foo1}" {if $someVar.0 eq $foo1} selected="selected" {/if} >{$foo1}</option>

      {/for}

                            </select>
                            <select name="hours" id="hours_{$foo.id}_{$foo.id}">
                              <option value="0">H</option>

      {for $foo1=1 to 8}

                              <option value="{$foo1}"  {if $someVar.1 eq $foo1} selected="selected" {/if}>{$foo1}</option>

      {/for}

                            </select>
                            <select name="minutes" id="minutes_{$foo.id}_{$foo.id}">
                              <option value="0"  >M</option>

      {for $foo1=10 to 60 step 10}

                              <option value="{$foo1}" {if $someVar.2 eq $foo1} selected="selected" {/if}>{$foo1}</option>

      {/for}

                            </select>
                            <input type="button" value="Save" class="button_pro" id="go_{$foo.id}" onClick="saveEstimate1(this.id)"  style="margin-top:5px;"></td>
                          <td id="td{$foo.id}"> {if $loggedUserId eq $foo.start_point}
                            <input type="button" class="button_pro" value="Cancel" id="{$foo.id}" onclick="updateToArchive(this.id,{$foo.email_user_ref_receiver},{$foo.email_user_ref_receiver},{$foo.priority})" />
                            <input type="button" class="button_pro" id="4" value="Done" name="{$foo.id}" onclick="updateTaskStatusMain(this.id,this.name,{$foo.email_user_ref_sender},{$foo.email_user_ref_receiver})" />
                            {/if}
                            {if $foo.task_status eq 3 }
                            <input type="button" class="button_pro" id="9" value="undo" name="{$foo.id}" onclick="undoDone(this.id,this.name,{$foo.email_user_ref_sender},{$foo.email_user_ref_receiver})" />

                             {/if}
                            <input type="button" class="button_pro" id="confirm_button" value="View" onclick="javascript:window.location.href='view-task?taskid={$foo.id}';" /></td>
                        </tr>
                         {/foreach}
                        </tbody>
                        {else}
                          <tbody class="tablesorter-no-sort {$class} " id="user_{$foo1.email_user_ref_receiver}" style="display:none">
    <tr id="0_0"><th colspan="7" align="left" style="padding-left:10px">{$heading}</th></tr> 
  </tbody>
                         <tbody id="{$class}" style="display:none">
                         <tr>
                         <td colspan="6">No Task Found</td>
                         </tr>
                         </tbody>
                        {/if}
                      {/foreach}
                        {else}
                        <tbody>
                        <tr id="0_0">
                          <td colspan="6">No Task Founds</td>
                        </tr>
                        </tbody>
                        {/if}

                      </table>
                    </div>
                    <div class="clearboth" style="padding-bottom:10px;"></div>
                    <div id="pagerrep{$foo.email_user_ref_receiver}" class="pager" >
                      <form>
                        <img src="addons/first.png" class="first"> <img src="addons/prev.png" class="prev">
                        <input type="text" class="pagedisplay">
                        <img src="addons/next.png" class="next"> <img src="addons/last.png" class="last">
                        <select class="pagesize" style="display:none">
                          <option selected="selected" value="50">50</option>
                          <option value="20">20</option>
                          <option value="30">30</option>
                          <option value="40">40</option>
                        </select>
                      </form>
                    </div>
                  </div> 

above is my template code. this also getting dynamically generated,

please help me solve my issue.

Mottie commented 11 years ago

Hi karthickkumarganesh!

The only thing I can think of that would cause that error is if the jquery.tablesorter.widgets.js file is not being loaded. Also are you using the latest version?

karthickkumarganesh commented 11 years ago

jquery.tablesorter.widgets.js seems to be loaded,

Error: TypeError: parsers[j] is undefined jquery.tablesorter.js Line: 252

got the above error in mozilla firefox

Uncaught TypeError: Cannot call method 'format' of undefined jquery.tablesorter.js Line: 252

got above error in chrome

karthickkumarganesh commented 11 years ago

this issue get fixed ,please remove applying dynamic Class Name and other Class Name expect tablesorter

Mottie commented 11 years ago

The only class name that is added to the table, besides tablesorter is the theme name, e.g. tablesorter-default.

You can force it to not even add that by setting the theme name to an empty string:

theme : ""

As for the error in Firefox, I can't duplicate it. Has it been resolved since this issue is closed? Or if it hasn't, I'd appreciate a live demo to help troubleshoot the problem, because it is difficult for me to decipher the above code into it's final HTML.