2012-04-24 2 views
0

데이터베이스를 사용하여 검색 템플릿을 저장하고로드하려고합니다. 이를 수행하는 동안 tmplLabel, tmplNames, tmplFilters의 값을 변경할 수 없습니다. loadTemplates() 함수를 호출하여 서버로 이동하여 데이터를 가져 와서 3 개의 변수에 저장합니다. 이 함수는 loadComplete()에서 호출됩니다. 템플릿의 값을 어떻게 재설정 할 수 있는지 알려주십시오. 나는 비슷한 것을 이야기하고있다 http://www.trirand.com/blog/jqgrid/jqgrid.html로드 중 데이터베이스에서 jqGrid의 검색 템플릿 필터

답변

0

검색 템플릿은 자주 사용되지 않는 흥미로운 기능입니다. 이를 사용하려면 검색 모듈의 parameterstmplNamestmplFilters (선택적으로 tmplLabel)을 사용해야합니다. 추가로 recreateFilter: true 옵션을 사용하는 것이 중요합니다. 그래서 당신은 당신이 이미 올바른 코드를 가지고 있다고 가정

var mySearchOptions = { 
     // it's just some options which you use 
     multipleSearch: true, 
     multipleGroup: true, 
     recreateFilter: true, 
     closeOnEscape: true, 
     closeAfterSearch: true, 
     overlay: 0 
    }, 
    $grid = $("#grid"); 

$grid.jqGrid({ 
    // ... your jqGrid options 
    loadComplete: function (data) { 
     // you should modify the next line correspond to the place of 
     // tmplNames and tmplFilters in the server response 
     if (data.tmplNames && data.tmplFilters) { 
      mySearchOptions.tmplNames = data.tmplNames; 
      mySearchOptions.tmplFilters = data.tmplFilters; 
     } 
    } 
}); 
$grid.jqGrid('navGrid', {/*navGrid option*/}, {/*Edit options*/}, {/*Add options*/}, 
    {/*Del options*/}, 
    mySearchOptions); 

의 옵션을 설정할 수 있습니다,하지만 당신은 recreateFilter: true 옵션을 사용하지 마십시오. 따라서 현재 옵션으로 대화 상자를 다시 생성하는 대신 이전에 열었던 검색 대화 상자가 표시됩니다.

P. jqGrid 4.3.2의 소스를 추가로 새로 고치는 것이 좋습니다 (the answer 참조). 더 나은 키보드 지원이 가능하며 검색 대화 상자에서 searchOnEntercloseOnEscape 옵션, afterChange 콜백 및 사용자 정의 컨트롤을 사용할 수 있습니다 (the answer 참조).