javascript - bootstrapTable 搜索
本文介绍了javascript - bootstrapTable 搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
如题,一开始有初始数据加载到表格上,我现在想实现选择完设备和时间,再点击搜索,然后向后台发送ajax请求,更新这个表格的数据,只有传的data不一样,该怎么写……现在脑子一片迷糊,我用的data-ajax=方法……求大神解救
解决方案
<div class="container">
<h1>Custom Ajax</h1>
<p>Use <code>ajax</code> option: A method to replace ajax call. Should implement the same API as jQuery ajax method.</p>
<table id="table"
data-toggle="table"
data-height="460"
data-ajax="ajaxRequest"
data-search="true"
data-side-pagination="server"
data-pagination="true">
<thead>
<tr>
<th data-field="id">ID</th>
<th data-field="name">Item Name</th>
<th data-field="price">Item Price</th>
</tr>
</thead>
</table>
</div>
<script>
var $table = $('#table');
// your custom ajax request here
function ajaxRequest(params) {
// data you need
console.log(params.data);
params.customParams = {}; // 这样添加自定义参数,也可以获取dom元素的值
}
</script>
点击搜索按钮refresh table(刷新表格)如果参数有改变ajaxRequest
里面会获取最新的参数值提交至服务器。
这篇关于javascript - bootstrapTable 搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文