【发布时间】:2019-04-24 12:33:12
【问题描述】:
我正在尝试为 bootgrid 控件设置搜索框,如示例页面 here 中所示。页面导航调用 ajax 调用,处理 ajax 调用的服务器方法接收 searchPhrase,但在搜索框中键入不会调用服务器方法。文档和各种问答都没有指导,this 是最接近的问题,但没有解决我的问题。
我在 ASP.NET MVC 网站上做这个,这里是相关的代码片段。
<div id="grid-command-buttons-header" class="bootgrid-header container-fluid">
<div class="row">
<div class="col-sm-12 actionBar">
<div class="search form-group">
<div class="input-group">
<span class="icon fa input-group-addon fa-search"></span>
<input type="text" class="search-field form-control" placeholder="Search">
</div>
</div>
</div>
</div>
</div>
<table class="table table-condensed table-hover table-striped" id="redisKeyResults">
<thead>
<tr>
<th data-column-id="KeyName" data-formatter="link" data-type="string" data-order="desc" data-identifier="true">Key</th>
<th data-column-id="KeyName" data-formatter="commands">Flush</th>
</tr>
</thead>
</table>
设置bootgrid的Javascript代码如下
$("#redisKeyResults").bootgrid({
ajax: true,
url: "RedisCacheKeyManagement/GetRedisKeyResultGrid",
post: function() {
return {
id: "b0df282a-0d67-40e5-8558-c9e93b7befed"
};
},
formatters: {
"commands": function(column, row) {
return "<button type=\"button\" class=\"btn btn-xs btn-danger command-delete\" data-row-id=\"" +
row.KeyName +
"\">Flush</button>";
},
"link": function(column, row) {
return "<a class=\"link-get\" data-row-id=\"" + row.KeyName + "\" href=\"" + row.link + "\">" + row.KeyName + "</a>";
}
}
})
【问题讨论】:
标签: asp.net-mvc jquery-bootgrid