【问题标题】:w2ui: ERROR: Cannot add records without recid. (obj: grid)w2ui:错误:无法添加没有 reci 的记录。 (对象:网格)
【发布时间】:2015-10-18 05:43:54
【问题描述】:

使用 w2ui 时出现以下错误:

ERROR: Cannot add records without recid. (obj: grid)

我使用模型的主键作为 recid,它与我的其他表一起工作得很好。但对于其中一个,它给出了这个错误。除了列之外,此表与其他表没有区别。下面是表格的代码。我在 Django 1.8 中运行它:

<script>
    $(function () {
        $("#grid").w2grid({
            name: "grid",
            show: {
                footer:true,
                toolbar:true
            },
            header:  "List of RTN Infos",
            columns: [
                { field:"app_no", caption:"Number", size:"30%" },
                { field:"app_name", caption:"Name", size:"30%" },
                { field:"app_retrieve_date", caption:"Retrieve Date", size:"30%" },
                { field:"app_deliver_info", caption:"Deliver Info", size:"30%" },
                { field:"app_deliver_mo", caption:"Deliver Month", size:"30%" },
                { field:"app_deliver_yr", caption:"Deliver Year", size:"30%" },
            ],
            records: [
                {% for i in table %}
                    { rec_id:"{{ i.id }}", 
                    app_no:"{{ i.app_no }}", 
                    app_name:"{{ i.app_name }}", 
                    app_retrieve_date:"{{ i.app_retrieve_date }}", 
                    app_deliver_info:"{{ i.app_deliver_info }}", 
                    app_deliver_mo:"{{ i.app_deliver_mo }}", 
                    app_deliver_yr:"{{ i.app_deliver_yr }}", 
                {% endfor %}
            ],
            onDblClick: function(event) {
                url = "/app/update_item/" + event["recid"]
                console.log(url)
                $("#modal").modal({remote:url})
                $("#modal").removeData()
            }
        }); 
    });
</script>

【问题讨论】:

    标签: javascript jquery django w2ui


    【解决方案1】:

    很确定您应该使用recid 而不是rec_id

            records: [
                {% for i in table %}
                    { **recid**:"{{ i.id }}", 
                    app_no:"{{ i.app_no }}", 
                    app_name:"{{ i.app_name }}", 
                    app_retrieve_date:"{{ i.app_retrieve_date }}", 
                    app_deliver_info:"{{ i.app_deliver_info }}", 
                    app_deliver_mo:"{{ i.app_deliver_mo }}", 
                    app_deliver_yr:"{{ i.app_deliver_yr }}", 
                {% endfor %}
            ],
    

    【讨论】:

      猜你喜欢
      • 2018-10-28
      • 2017-08-07
      • 2021-01-14
      • 2021-06-10
      • 1970-01-01
      • 2022-11-15
      • 1970-01-01
      • 2016-12-06
      • 1970-01-01
      相关资源
      最近更新 更多