Awa*_*dra 2 html asp.net asp.net-mvc jquery twitter-bootstrap
我检查了你的例子,它在你的例子中工作,但是当我在我的例子中尝试它时,它不起作用.我不知道我在哪里犯错误.是我使用旧的jQuery文件?我在这里发布了整个HTML代码.
HTML代码
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<title>Refresh method with new url</title>
<meta charset="utf-8">
<link href="~/Content/bootstrap.min.css" rel="stylesheet" />
<link href="~/Content/bootstrap-table.css" rel="stylesheet" />
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script src="~/Scripts/bootstrap.min.js"></script>
<script src="~/Scripts/bootstrap-table.js"></script>
</head>
<body>
<div class="container">
<div class="ribbon">
<a href="https://github.com/wenzhixin/bootstrap-table-examples/blob/master/409.html">View Source on GitHub</a>
</div>
<h1>Refresh method with new url(<a href="https://github.com/wenzhixin/bootstrap-table/issues/409">#409</a>).</h1>
<div class="toolbar">
<button id="refresh" class="btn btn-default">Refresh</button>
</div>
<table id="table"
data-toggle="table"
data-toolbar=".toolbar"
data-url='/Report/GetShipments'>
<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');
$(function () {
$('#refresh').click(function () {
$table.bootstrapTable('refresh', {
url: '/Report/ShowShipment'
});
});
});
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
控制器代码.
public class ReportController : Controller
{
// GET: Report
public ActionResult Index()
{
return View();
}
public ActionResult GetShipments()
{
//IShipments shipments = new ShipmentsClient();
//var data = shipments.GetShipments(string.Empty, string.Empty, string.Empty, string.Empty);
//return Json(data, JsonRequestBehavior.AllowGet);
return Json("test" , JsonRequestBehavior.AllowGet);
//return new Json()
}
public ActionResult ShowShipment()
{
//IShipments shipments = new ShipmentsClient();
//var data = shipments.GetShipments(string.Empty, string.Empty, string.Empty, string.Empty);
//return Json(data, JsonRequestBehavior.AllowGet);
return Json("test", JsonRequestBehavior.AllowGet);
//return new Json()
}
public ActionResult Test()
{
return View();
}
}
Run Code Online (Sandbox Code Playgroud)
当页面加载并点击GetShipment()控制器中的方法,然后我们点击刷新按钮,它应该点击ShowShipment()方法,但不幸的是它总是命中GetShipment()方法.我不知道自己犯了什么错误.
wen*_*nyi 11
您可以使用刷新方法:
$table.bootstrapTable('refresh', {
url: 'new url'
});
Run Code Online (Sandbox Code Playgroud)
我在这里添加了一个例子:http://issues.wenzhixin.net.cn/bootstrap-table/#issues/409.html
文档:http://bootstrap-table.wenzhixin.net.cn/documentation/#methods
希望能帮到你.
| 归档时间: |
|
| 查看次数: |
26829 次 |
| 最近记录: |