2013-03-21 29 views
0

我試圖用添加編輯包括在navGrid德爾功能。 當我嘗試添加一些行會出現這樣的錯誤:的jqGrid:c.p.colModel [E] .formoptions是不確定的

c.p.colModel[e].formoptions is undefined. 

當我嘗試編輯德爾出現類似的錯誤。

我試圖使用「包含」在navGrid中的添加,編輯和刪除功能。 當我嘗試添加一些行時出現此錯誤:c.p.colModel [e] .formoptions未定義。 當我嘗試編輯或刪除類似的錯誤出現。有人可以幫我解決這個問題嗎?

我網的的代碼是:

function mypricecheck(value, colname) { 
    if (value < 0 || value > 20) 
     return [false, "Please enter value between 0 and 20"]; 
    else 
     return [true, ""]; 
} 

$(function() { 
    var lastSel; 
    $("#list").jqGrid({ 
     url: "php.php", 
     datatype: "json", 
     mtype: "POST", 

     colNames: ['Index', 'ac_n_quad', 'ac_l_circ', 'ac_n_circ', 'ac_fin_g', 'ac_pot', 'ac_volt', 'ac_n_polos', 'ac_t_prot', 'ac_v_prot', 'ac_cabo', 'ac_fd', 'ac_fp', 'ac_ctr', 'ac_pot_a', 'ac_pot_b', 'ac_pot_c', 'ac_pos_1', 'ac_pos_2', 'ac_calc'], 

     colModel: [ 
      { name: 'index', index: 'index', width: 65, key: true, hidden: true }, 
      { name: 'ac_n_quad', index: 'ac_n_quad', width: 110 }, 
      { 
       name: 'ac_l_circ', index: 'ac_l_circ', width: 65, editable: true, editoptions: { 
        dataInit: function (elem) { 
         $(elem).autocomplete({ 
          source: "autocomplete.php?extraparam=ac_l_circ", 
          select: function (event, ui) { 
           $(elem).val(ui.item.value); 
          } 
         }); 
        } 
       } 
      }, 
      { name: 'ac_n_circ', index: 'ac_n_circ', width: 120, editable: true, editrules: { custom: true, custom_func: mypricecheck } }, 
      { 
       name: 'ac_fin_g', index: 'ac_fin_g', width: 75, editable: true, editoptions: { 
        dataInit: function (elem) { 
         $(elem).autocomplete({ 
          source: "autocomplete.php?extraparam=ac_fin_g", 
          select: function (event, ui) { 
           $(elem).val(ui.item.value); 
          } 
         }); 
        } 
       } 
      }, 
      { name: 'ac_pot', index: 'ac_pot', width: 55, editable: true, formatter: 'number', formatoptions: { decimalPlaces: 0, thousandsSeparator: '.' } }, 
      { name: 'ac_volt', index: 'ac_volt', width: 60, editable: true, edittype: "select", formatter: "select", editoptions: { value: "110:110; 220:220" } }, 
      { name: 'ac_n_polos', index: 'ac_n_polos', width: 100, editable: true, edittype: "select", formatter: "select", editoptions: { value: "1:1; 2:2; 3:3" } }, 
      { name: 'ac_t_prot', index: 'ac_t_prot', width: 100, editable: true, edittype: "select", formatter: "select", editoptions: { value: "DISJUNTOR:DISJUNTOR; FUSÍVEL:FUSÍVEL" } }, 
      { name: 'ac_v_prot', index: 'ac_v_prot', width: 70, editable: true }, 
      { 
        name: 'ac_cabo', index: 'ac_cabo', width: 60, editable: true, editoptions: { 
         dataInit: function (elem) { 
          $(elem).autocomplete({ 
           source: "autocomplete.php?extraparam=ac_cabo", 
           select: function (event, ui) { 
            $(elem).val(ui.item.value); 
           } 
          }); 
         } 
        } 
      }, 
      { name: 'ac_fd', index: 'ac_fd', width: 55, editable: true, formatter: 'number', formatoptions: { decimalPlaces: 1 } }, 
      { name: 'ac_fp', index: 'ac_fp', width: 55, editable: true, formatter: 'number', formatoptions: { decimalPlaces: 1 } }, 
      { name: 'ac_ctr', index: 'ac_ctr', width: 60 }, 
      { name: 'ac_pot_a', index: 'ac_pot_a', width: 70 }, 
      { name: 'ac_pot_b', index: 'ac_pot_b', width: 70 }, 
      { name: 'ac_pot_c', index: 'ac_pot_c', width: 70 }, 
      { name: 'ac_pos_1', index: 'ac_pos_1', width: 70 }, 
      { name: 'ac_pos_2', index: 'ac_pos_2', width: 70 }, 
      { name: 'ac_calc', index: 'ac_calc', width: 65 } 
     ], 
     cmTemplate: { align: "center" }, 
     ondblClickRow: function (id, iRow, iCol, e) { 
      if (id) { 
       if (id !== lastSel) { 
        $("#list").restoreRow(lastSel); 
        var cm = $("#list").jqGrid('getColProp', 'ac_ctr'); 
        cm.editable = false; 
        $("#list").editRow(id, true); 
        $("input, select", e.target).focus().select(); 
        cm.editable = true; 
        lastSel = id; 
       } else { 
        $("#list").restoreRow(lastSel); 
        lastSel = ""; 
       } 
      } 
     }, 
     editurl: "edit.php", 
     autowidth: "true", 
     height: "auto", 
     rowNum: 10, 
     rowList: [10, 20, 30, 40, 50, 60, 70, 80, 90, 100], 
     sortname: "ac_n_quad, ac_n_circ", 
     sortorder: "asc", 
     pager: '#pager', 
     viewrecords: true, 
     gridview: true, 
     caption: "Tabela circ_69" 
    }); 

    $("#list").jqGrid('navGrid', '#pager', { 
     add: true, 
     addtext: "Adicionar", 
     edit: true, 
     edittext: "Editar", 
     del: true, 
     deltext: "Excluir", 
     search: false, 
     refresh: false 
    }, 
    { 
     reloadAfterSubmit: true 
    }, // add options 
    { 
     reloadAfterSubmit: true 
    }, // edit options 
    { 
     reloadAfterSubmit: true 
    } // del options 
    ); 

    $("#list").jqGrid('gridResize'); 
}); 

螢火顯示錯誤是在6083線:

try { nm = g.p.colModel[i].formoptions.label; } catch (e) {} 
+0

首先,如果您報告錯誤,您應該始終使用'jquery.jqGrid.src.js'而不是'jquery.jqGrid.min.js'。此外,您通常會看到錯誤發生處的'jquery.jqGrid.src.js'行。這些信息也可能有幫助。秒應該包含用於創建jqGrid並調用'navGrid'的JavaScript代碼。 – Oleg 2013-03-21 15:14:13

+0

感謝回覆@Oleg! :D我改變了這一點。 錯誤在'6083行:try {nm = g.p.colModel [i] .formoptions.label; } catch(e){}'。我將包含上面的代碼! – mailazs 2013-03-21 15:20:55

+0

@Oleg我在帖子中包含了我的代碼。我是否必須執行某些操作來執行操作?或者我做對了嗎? – mailazs 2013-03-21 16:40:20

回答

0

我不知道在那裏你可以看到錯誤「cpcolModel [E] .formoptions是未定義的。「該代碼

try { nm = g.p.colModel[i].formoptions.label; } catch (e) {} 

做列「ac_n_circ」的驗證過程中產生的異常,但異常會被逮住(見catch (e) {}部分)。所以不應該顯示錯誤消息。

我同意the line的代碼是不完美的,但它仍然不是一個錯誤。如果你想elliminate例外,你可以再補充

formoptions: {} 

到您使用editrules列。

+0

我不知道爲什麼,我不知道如何,但錯誤現在消失了,我什麼也沒改變!奇怪的事情發生!哈哈哈現在只是我的編輯不工作!但是謝謝你的時間和你的幫助! :) – mailazs 2013-03-21 17:54:08

+1

@mzs_newbie:不客氣!我想你在調試器中執行了代碼並使用了「停止異常」選項。這是您可以選擇的調試器中的一個按鈕。 – Oleg 2013-03-21 17:54:20

+0

是的,我做到了!新手!哈哈哈再次感謝:) – mailazs 2013-03-21 18:31:38