所以我隐藏了我的 Flexigrid,直到有搜索匹配结果。
所以我的flexigrid初始化:
flexigrid({
url ='myUrl',
onSubmit: showFlexigrid(),
//my other flexigrid options
});
function showFlexigrid(celDiv, id) {
var flexiGrid = $('#gridTablegSearchProperty')
if (!flexiGrid.is(":visible")) {
if (id) { //got at least one result if id is not undefined
$('#flexigridWrapper').show();
} else {
//I want to display a no results found message to the user here
//but this won't work because the showFlexigrid function is
//not called on flexiReload()
console.log('no results');
}
}
}
//in my $document.ready my search button click implementation:
$("#btnSearch").click(function () {
$('#gridTablegSearchProperty').flexReload();
});
<!--And my html-->
<div id="flexigridWrapper" style="display:none;">
<div class="row">
<div class="col-lg-12">
<div class="well">
<div class="well-inner">
<table id="gridTablegSearchProperty"></table>
</div>
</div>
</div>
</div>
</div>
因此,无论是我在我的 flexigrid“实例化”中绑定到的 flexigrid onSubmit 还是 onSuccess,都不会在 .flexReload 上调用,除非至少返回记录。我没有看到每次都会触发 flexigrid 选项,甚至 onSubmit 也没有这样做。