【问题标题】:django window popup with table details带有表格详细信息的 django 窗口弹出窗口
【发布时间】:2018-03-11 03:55:55
【问题描述】:

我想在模板中创建一个按钮,如果我按下 View,我希望显示一个弹出窗口,并且在该弹出窗口中我想显示来自 models.py 的表格。

基本上,我希望该弹出窗口包含所有列名和该表格显示的所有日期。如果可能的话,使用分页。

这是我的 seaerch_table.html

的一部分
<script>
    $("#mytable").dialog({autoOpen: false});
    $("#opener").click(function () {
        $("#mytable").dialog("open");
    });
</script>

    <table class="table table-bordered sortable table-hover" id="mytable">
        <thead>
        <tr>
            <th>Id</th>
            <th>Title</th>
            <th>Url</th>
            <th>View All Info</th>
        </tr>
        </thead>
        <tbody>
        {% for lists in details %}
            <tr>
                <td>{{ lists.id }}</td>
                <td>{{ lists.title }}</td>
                <td><a href="{{ lists.url }}" target="_blank">{{ lists.url }}</a></td>
                <td>
                    <button id="opener">View</button>
                </td>
            </tr>

        {% endfor %}
        </tbody>
    </table>

它只在模板中显示 3 个字段...我想在弹出窗口时再添加 2 个字段,其中包括 Createdat 和 Descriptions 字段。我不想在那个弹出窗口上做任何特别的事情...只显示 mysql 中的整个表(包括创建的列at 和 description

有人可以帮我吗?

谢谢

【问题讨论】:

    标签: jquery html mysql django


    【解决方案1】:
    $( function() {
    $( "#dialog1" ).dialog({
    autoOpen: false,
    show: {
      effect: "blind",
      duration: 1000,
      width: "auto", 
      height: "auto",
      position: "left", 
    
    },
    hide: {
      effect: "explode",
      duration: 1000,
      width: "auto", 
      height: "auto",
      position: "left",
    }
    });
    
    $( "#opener1" ).on( "click", function() {
    $( "#dialog1" ).dialog( "open" );
    });
    });
    

    html:

    <p id="opener1" style="color:green; margin: 0%">show table</p>
    <div id="dialog1" title="Number of entry failed.">
    <table class="table table-bordered sortable table-hover" id="mytable">
        <thead>
        <tr>
            <th>Id</th>
            <th>Title</th>
            <th>Url</th>
            <th>View All Info</th>
        </tr>
        </thead>
        <tbody>
        {% for lists in details %}
            <tr>
                <td>{{ lists.id }}</td>
                <td>{{ lists.title }}</td>
                <td><a href="{{ lists.url }}" target="_blank">{{ lists.url }}</a></td>
                <td>
                    <button id="opener">View</button>
                </td>
            </tr>
    
        {% endfor %}
        </tbody>
    </table>
     </div>
    

    【讨论】:

      猜你喜欢
      • 2012-11-26
      • 2013-03-09
      • 2012-06-10
      • 2014-06-19
      • 2020-01-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多