无法设置在举表使用jQuery的数据url值 [英] Unable to set data-url value using jquery in bootstrap table

查看:123
本文介绍了无法设置在举表使用jQuery的数据url值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我检查你的榜样,它的工作在你的例子,但是当我在我的例子试了一下,然后它不工作。我不知道我做的错误。是我使用jQuery的旧文件。我张贴在这里整个HTML code。

I checked your example and it's working on your example but when I tried it in my example then it doesn't work. I don't know where I am doing mistakes. Is I am using old jquery files. I am posting whole html code on here.

HTML code

HTML CODE

@{
    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>

控制器code。

Controller code.

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();
        }

    }

在页面加载,然后它击中GetShipment()方法OG控制器,并当我们点击刷新按钮,那么它应该打ShowShipment方法,但不幸的是它总是热GetShipment()方法。我不知道我在做什么错误。

When page load then it hit GetShipment() method og controller and when we click refresh button then it should hit ShowShipment method but unfortunately it always hot GetShipment() method. I don't know what mistake I am doing.

谢谢,
Awadhendra

Thanks, Awadhendra

推荐答案

您可以使用刷新方法:

$table.bootstrapTable('refresh', {
    url: 'new url'
});

我在这里补充一个例子: http://issues.wenzhixin.net .CN /引导表/ 409.html

的文档: http://bootstrap-table.wenzhixin.net.cn/文档/#方法

希望能帮助你。

这篇关于无法设置在举表使用jQuery的数据url值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆