【问题标题】:Jquery Jtable is not working for 2nd clickJquery Jtable 不适用于第二次点击
【发布时间】:2015-05-12 11:10:49
【问题描述】:

我正在尝试在我的项目中使用 JTable,当单击一个按钮时,需要显示 JTable,当我单击另一个按钮时,需要显示另一个数据,当我再次返回时单击相同的 JTable 按钮, JTable 没有填充我不确定为什么会这样。 我的代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>jQuery jTable Setup in java</title>
<!-- Include one of jTable styles. -->
<link href="css/metro/blue/jtable.css" rel="stylesheet"
    type="text/css" />
<link href="css/jquery-ui-1.10.3.custom.css" rel="stylesheet"
    type="text/css" />
<!-- Include jTable script file. -->
<script src="js/jquery-1.8.2.js" type="text/javascript"></script>
<script src="js/jquery-ui-1.10.3.custom.js" type="text/javascript"></script>
<script src="js/jquery.jtable.js" type="text/javascript"></script>
<script type="text/javascript">
//  $(document).ready(function() {
    function getUser(){
        $('#StudentTableContainer').jtable({
            title : 'Students List',
            actions : {
                listAction : 'Controller?action=list'
            },
            fields : {
                studentId : {
                    title : 'Student Id',
                    width : '30%',
                    key : true,
                    list : true,
                    create : true
                },
                name : {
                    title : 'Name',
                    width : '30%',
                    edit : false
                },
                department : {
                    title : 'Department',
                    width : '30%',
                    edit : true
                },
                emailId : {
                    title : 'Email',
                    width : '20%',
                    edit : true
                }
            }
        });
        $('#StudentTableContainer').jtable('reload');




    }
    //);
    function getAdmin()
    {
        var html='';
        html +='<h1>I am working</h1>';
        $("#StudentTableContainer").html(html);
    }
</script>

</head>
<body>
<button onclick="getUser()"  >User</button>
<button onclick="getAdmin()">Admin</button>
    <div style="width: 80%; margin-right: 10%; margin-left: 10%; text-align: center;">
        <h4>jQuery jTable Setup in java</h4>
        <div id="StudentTableContainer"></div>
    </div>
</body>
</html>

【问题讨论】:

    标签: jquery html jquery-jtable


    【解决方案1】:

    如果您想在单击按钮时加载表格,例如在按钮“Admin”中,您需要使用 jtable('load'),代码如下:

    function getAdmin(){
        $("#StudentTableContainer").jtable('load');
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多