2014-05-12 7 views
0
데이터 테이블

외부 길이 (선택 옵션) 내가 DataTables를 사용하고 내가 테이블의 외부로 내 길이 (선택 옵션)을 싶습니다Datatables -

(예 : 내 DIV합니다.).

+0

, 사용자 정의를 필요로'선택 '드롭 다운 일 에서 네이티브 datatable 길이 드롭 다운 상자처럼 행동해야합니다. –

+0

더 중요한 이유는 길이 (선택 옵션)가 테이블 외부에 있어야하는 이유입니다. 원래 기능에 추가하거나 제거하려는 기능은 무엇입니까? –

+0

Navbar로 이동하고 싶습니다. – Sosth

답변

0

전체 변경 길이 드롭 다운을 테이블 바깥으로 복사하여 직접 이동할 수 없습니다.

대신 당신이 원하는 어느 새 드롭 다운을 만들 수 있지만, DataTable의 호출에 다음과 같은 설정 -

<select name='length_change' id='length_change'> 
     <option value='50'>50</option> 
     <option value='100'>100</option> 
     <option value='150'>150</option> 
     <option value=''>All</option> 
    </select> 

`var oTable = $('#sample_1').dataTable({ 
..... 
"bLengthChange": false,  //This will disable the native datatable length change 
..... 
... 
"fnServerParams": function (aoData) { 
    aoData.push({ "name": "length_change", "value": $('#length_change').val() }); 
}, 
..... 
.... 
}); 
` 

The `aoData.push` will send the selected value of the customer length change to the server. 

In the Model Class from where the array will be returned for the datatable, include the pushed value to the limit. 

i.e. if `$postData` is the array of posted values to the server then - 

`if($postData['length_change']) 
    $limit = (int) $postData['length_change']; 
else 
    $limit = _DEFALUT_VALUE; 

`

나는 그것이 도움이되기를 바랍니다.

0

DataTables은 1.10+ 페이지의 길이 제어를 사용자 정의에 대한 built-in method을 가지고 v에 : 여기

$('#example').DataTable({ 
    //specify values for drop down 
    "lengthMenu": [[5, 10, 50, 100, 250, -1], [5, 10, 50, 100, 250, "All"]], 
    //set the default to 100 
    "pageLength": 100 
}); 

Fiddle Demo이다.

1

새로운 선택 형태를

<select name='length_change' id='length_change'> 
    <option value='50'>50</option> 
    <option value='100'>100</option> 
    <option value='150'>150</option> 
    <option value='200'>200</option> 
</select> 

초기화 dataTables

을 만들
var oTable = $('#example').DataTable({}); 

추가 기능 .change

$('#length_change').change(function() { 
    oTable.page.len($(this).val()).draw(); 
}); 

참조 : 당신은 의미 https://datatables.net/reference/api/page.len()