사용자 도구

사이트 도구


wiki:javascript:datatables:datatables

DataTables

  • description : DataTables
  • author : 오션
  • email : shlim@repia.com
  • lastupdate : 2023-01-03 Mon


DataTables

function column().search(input[, regex[, smart[, caseInsen]]])


function column.search( input [, regex[, smart[, caseInsen]]] )
 
function column.search( input )
 
function column.search( input, regex )
 
function column.search( input, regex, smart )
 
function column.search( input, regex, smart, caseInsen )


Description :
Set the search term for the column from the selector. Note this doesn't actually perform the search,
but rather queues it up - use draw() to perform the search and display the result.

selector에 컬럼에 대한 검색어를 설정합니다. 이것은 실제로 검색을 수행하는 것이 아니고,
검색을 대기하게 합니다. 검색을 실행하고, 결과를 표시하려면 draw()를 사용하십시오.


function column.search( input )

input 파라미터 ☛ string 타입의 파라미터인 input은 필수, 선택한 컬럼에 적용할 검색 문자열
( Search string to apply to the table. )

function column.search( input, regex )

regex 파라미터 ☛ boolean 타입의 파라미터인 regex는 선택, default는 false
정규식(regex, regular expression)으로 처리(true) 또는 비처리(default, false)
( Treat as a regular expression (true) or not (default, false). )

function column.search( input, regex, smart )

smart 파라미터 ☛ boolean 타입의 파라미터인 smart는 선택할 수 있고, default는 true
스마트 검색을 수행(default, true)하거나, 수행하지 않습니다(false)
( Perform smart search (default, true) or not (false). )
스마트 검색을 수행하기 위해 DataTables는 정규식을 사용하므로, 이 메소드에 두 번째 파라미터를 사용하는 정규식의 활성화 경우,
두 개의 정규식이 충돌하여 예상치 못한 결과를 유발할 수 있으므로, 스마트 검색을 비활성화하는 것이 좋습니다.

function column.search( input, regex, smart, caseInsen )

caseInsen 파라미터 ☛ boolean 타입의 파라미터인 caseInsen은 선택할 수 있고, default는 true
대소문자를 구분(case-insensitive)하지 않는 일치를 수행하거나(기본값, true), 대소문자를 구분(false)합니다.

적용 예제

rmrScript.js에서

1  else if(column.index() == 2) {
2      var select = $('<select style="margin-left: 0.5em; display: inline-block; width: auto; border: 1px solid #aaa; border-radius: 3px; padding: 5px; background-color: transparent; outline-offset: -2px;"><option value="">담당자 검색</option></select>')
3          .appendTo(selectbox)
4          .on( 'change', function() {
5              var text = $(this).find('option:selected').text();
6              var val = $.fn.dataTable.util.escapeRegex($(this).val());
7              if(text != '담당자 검색' && jQuery.isEmptyObject(val)) val = '미지정';
8              column.search( val ? '^' + val + '$' : '', true, false )
9              .draw();


상기 코드 8번 라인에서

8              column.search( val ? '^' + val + '$' : '', true, false )


val ? '^' + val + '$' : '' 는 필수인 input 파라미터, 여기서는 regex로 표시하도록 설정되어 있음

삼항 연산자, 값(val)이 있으면 ⇒ regex로 값을 표시( '^' + val + '$' ), 값이 없으면 ⇒ 여백 '' 으로 표시

두 번째 매개변수인 true는 정규식으로 처리하도록 true로 설정

세 번째 매개변수인 false는 스마트 검색을 비활성화로 설정

/var/services/web/dokuwiki/data/pages/wiki/javascript/datatables/datatables.txt · 마지막으로 수정됨: 2023/01/13 18:44 (바깥 편집)