0
jquery 그리드 위에 검색 상자가 있습니다. 사용자가 어떤 값을 반환하는 문자열을 입력 할 때까지 검색 키 입력 이벤트에Jquery Grid Search 이벤트 - 그리드를 강제로 다시로드하는 방법
Search: <input type="text" value="" id="searchInput" placeholder="Enter Document Type"/>
은 모든 것이 잘 작동합니다. 그리드는 보통 '발견 된 레코드 없음'을 보여줍니다. 이 시점부터 검색이 끊어집니다.
이유를 조사한 결과, postData 객체/속성에 원래의 Ajax 반환 격자 행이 더 이상 포함되어 있지 않음을 발견했습니다. 따라서 후속 검색은 빈 그리드를 걸러 내려고합니다.
이 시점에서 (위치가 재로드() 인 경우) 그리드를 강제로 다시로드하려면 어떻게해야합니까? 페이지의 새로 고침은 부분 페이지이므로 사용자가 그리드가없는 이전 페이지로 되돌아 가게합니다.
<script type="text/javascript">
$(document)
.ready(function() {
'use strict';
showWebTour();
getAllAttachments();
$('#searchInput')
.on('change keyup paste',
function() {
var searchtext = $(this).val();
var grid = $('#documentList');
if ($("#documentList tr").length == 0 && searchtext.length == 0) {
location.reload();
}
var postdata = grid.jqGrid('getGridParam', 'postData');
// BUG: When Search returns no records, postData no longer exists so next search always fails
var myfilter = {
groupOp: "OR",
rules: []
};
myfilter.rules.push({
field: "DocumentType",
op: "cn",
data: searchtext
});
$.extend(postdata,
{
filters: myfilter
});
$("#gbox_documentList").show();
if ($('#empty-documentList', $('#gbox_documentList').parent()).length) {
$('#empty-documentList', $('#gbox_documentList').parent()).remove();
}
grid.jqGrid('setGridParam',
{
search: searchtext.length > 2,
postData: postdata
});
grid.trigger("reloadGrid",
[
{
page: 1
}
]);
});
});
function getAllAttachments() {
if (typeof ($('#refreshDocs') != 'undefined')) {
$('#refreshDocs').off('click');
}
$.ajax({
url:
'@Url.Action("AttactmentViewDocuments", "Document")[email protected]&[email protected]',
dataType: "json",
type: 'GET',
beforeSend: function() {
$('.all-documents-loading')
.css({
"display": "block"
});
$('.attached-documents-loading')
.css({
"display": "block"
});
$('.generated-documents-loading')
.css({
"display": "block"
});
},
success: function (data) {
bindDocumentList(data.GridData);
$('.jqgfirstrow').hide();
},
error: function(xhr, response, status) {
/* Let user know that could not load data */
},
complete: function() {
$('.all-documents-loading')
.css({
"display": "none"
});
$('.attached-documents-loading')
.css({
"display": "none"
});
$('.generated-documents-loading')
.css({
"display": "none"
});
}
});
}
당신이 설명 할 수있는 방법을 검색 작업 , 데이터베이스에서 새 데이터를 생성하거나 클라이언트에서 필터링하고 있습니까? 측면 –