2010-06-08 3 views
1

나는 $에서 예를 들어 Dynamic_value를 전달할 수있는 방법동적 JQuery와 테이블 정렬

$("#sort-table").tablesorter( 
     {headers: { 

      0: { 
       sorter: false 
       }, 

      dynamic_value: { 
        sorter: false 
      } 
     } 
    }); 

http://tablesorter.com/docs/example-options-headers.html를 사용하고 있습니다 ('. 헤더'). 길이는?

<thead> 
    <tr> 
     <th width="20"><?php echo $check;?></th> 
     <th class="header">FullName</th> 
     <th class="header">Rank</th> 
     <th class="header">Email</th> 
     <th class="header">Position</th> 
     <th width="15"></th> 
    </tr> 

답변

4

은 당신이 수를 동적으로 계산되어야하는 특정 컬럼에 sorter: false을 적용한다고 가정합니다. 내가 아는 한, 자바 스크립트는 대한 직접적인 구문을 허용하지 않습니다, 그래서 당신은 다음과 같이 이동해야합니다 : 그것은 우아한 아니다

headerset = { 
       0: { 
        sorter: false 
       } 
      // any other static column here 
      }; 
// repeat the following line for each dynamic value 
headerset[dynamicvalue] = { sorter: false }; 
// the variable headerset now contains the header settings 
// you can apply them to the tablesorter 
$("#sort-table").tablesorter({ headers: headerset }); 

을,하지만 작동합니다. 위의 질의에 대한

+0

감사합니다. 내가 원하는대로 작동합니다. – kn3l

0

솔루션은 다음과 같습니다 :

$(document).ready(function() 
{ 
    // extend the default setting to always sort on the first column 
    $.tablesorter.defaults.sortList = [[0,0]]; 
    var newheader={ 
     1:{sorter:false}, 
     4:{sorter:false} 
    }; 
    $(".tablesorter").tablesorter({headers:newheader}); 
}); 

우리가 할 수는 다음과 같이 JSON 문자열을 사용하여 옵션을 확장합니다. 솔루션을 사용하여 bin을 만들었습니다. http://codebins.com/codes/home/4ldqpcd