【问题标题】:JQGrid Formatter generating incorrect code after in-line edit在线编辑后 JQGrid Formatter 生成不正确的代码
【发布时间】:2016-06-16 16:32:02
【问题描述】:

在对该行执行内联编辑后,我的“格式化程序”生成了不正确的代码。在我保存我的内联编辑并尝试单击该行的“编辑:##”后,我得到一个 404。

1) 当页面首次加载(或重新加载)时,您可以看到链接的正确 URL 和 html 代码:

2) 现在我执行内联编辑并单击 SAVE JqGrid Actions 图标:

3) ERROR--> EDIT 链接现在似乎包含两次相同的 HTML 代码:

我的网格的 colModel:

colModel: [

       {"width":"50","fixed":true,"search":true,"editable":false,"searchoptions":{"clearSearch":false,"sopt":["eq","ne","lt","le","gt","ge","nu","nn"]},"sortable":true,"formatter":fullEditTemplate,"name":"id","label":"ID"},

{"formatter":"actions","formatoptions":{"afterSave":easygrid.afterSave('templateGrid_table'),"onError":easygrid.onError('templateGrid_table'),"keys":true,"delbutton":false},"searchoptions":{"clearSearch":false},"search":false,"name":"actions","width":"50","sortable":false,"resizable":false,"label":"Edit","fixed":true,"editable":false},

{"formatter":templateDuplicateFormat,"label":"Duplicate","searchoptions":{"clearSearch":false},"search":false,"editable":false,"name":"version","sortable":true,"width":"70"},

{"searchoptions":{"clearSearch":false,"sopt":["cn","nc","eq","ne","bw","ew","nu","nn"]},"editable":true,"sortable":true,"width":"250","name":"templateName","search":true,"label":"Template Name"}


],

这是完整的EditTemplate函数:

function fullEditTemplate(cellvalue, options, rowObject) {
        return "<a href='${g.createLink(controller: "template", action: "edit")}/" + cellvalue + "'> Edit: " + options.rowId + "</a> ";
}

谢谢!!

【问题讨论】:

    标签: javascript jquery jqgrid grid


    【解决方案1】:

    这是因为您没有指定对应于 fullEditTemplate 的 unformmater。只要网格是只读的,格式化程序就可以很好地与非格式化程序一起工作,但是如果我们需要内联或表单编辑意外行为,例如您所发生的事情。

    Documentation这里是你应该如何解决它

    首先在 colModel 中添加 unformatter

     {"width":"50","fixed":true,"search":true,"editable":false,"searchoptions":{"clearSearch":false,"sopt":["eq","ne","lt","le","gt","ge","nu","nn"]},"sortable":true, "unformat":fullEditTemplateUnformat,"formatter":fullEditTemplate,"name":"id","label":"ID"},
    

    你定义 unformatter 函数如下。

    function fullEditTemplateUnformat( cellvalue, options, cell){
        var anchortext= $('a', cell).text();
        var resultValue=anchortext.split(":"); // resultValue[0] is the Edit and  resultValue[1] is what we are looking for
        return resultValue[1].trim();
    }
    

    【讨论】:

      猜你喜欢
      • 2012-10-15
      • 1970-01-01
      • 2011-11-18
      • 1970-01-01
      • 1970-01-01
      • 2016-09-06
      • 1970-01-01
      • 1970-01-01
      • 2012-01-14
      相关资源
      最近更新 更多