2011-02-02 97 views
0

我有一個網格,它維護某個實體(如文檔)元數據的映射。在這種情況下,我們只需添加或編輯。編輯只是爲了消除記錄禁用內聯和單元格編輯,只允許在jqgrid中進行表單編輯

由於這種情況,我們沒有意義使用單元格或內聯編輯。表格編輯選項將是最好的

然而,這些表格只顯示其中有「可編輯:真正的」那些列

那麼,如何在網格中的一個禁止編輯,使其只爲形式?

onSelectRow根本不會觸發。我錯過了什麼?我使用的jqGrid 3.8

這是我曾嘗試:

var metaGrid = jQuery("#" + nodeMetaDataGrid); 
     metaGrid.jqGrid({ 
      pager: jQuery("#" + nodeMetaDataGridPager), 
      emptyrecords: "No records to view", 
      sortname: 'Id', 
      rowNum: 30, 
      rowList: [50, 100, 'ALL'], 
      sortorder: "asc", 
      height: "auto", 
      autowidth: true, 
      colNames: ['Id', 'Meta Data Type', 'Meta Data Value', 'Status', 'Date Added', 'Date Removed'], 
      colModel: [ 
       { name: 'Id', index: 'Id', hidden: true, key: true }, 
       { name: 'MetaType', index: 'MetaType', width: 30, editable: false, edittype: "select", editoptions: { dataUrl: "My/GetList"} }, 
       { name: 'MetaValue', index: 'MetaValue', width: 30, editable: false, editrules: { required: true} }, 
       { name: 'Status', index: 'Status', width: 10, editable: false, edittype: "select", editoptions: { value: "A:Active;I:Inactive"} }, 
       { name: 'DateAdded', index: 'DateAdded', width: 20, editable: false }, 
       { name: 'DateRemoved', index: 'DateRemoved', width: 20, editable: false } 
       ], 
      datatype: 'json', 
      viewrecords: true, 
      mtype: 'GET', 
      jsonReader: { 
       root: "rows", 
       page: "page", 
       total: "total", 
       records: "records", 
       repeatitems: false, 
       userdata: "userdata" 
      }, 
      url: getUrl, 
      multiselect: false, 
      //editurl: "someurl" 
      caption: "Available Meta Data", 
      onSelectRow: function (id) { 
       alert("Before Iff statement"); 
       if (id && id !== lastSel) { 
        alert("hi, selected"); 
        jQuery(this).restoreRow(lastSel); 
        var cm = metaGrid.jqGrid('getColProp', 'MetaType'); 
        cm.editable = false; 
        //grid.jqGrid('addRow', id, true, null, null, 'someURL'); 
        //cm.editable = true; 
        lastSel = id; 
       } 
      } 
     }) 
     .navGrid("#" + nodeMetaDataGridPager, { view: false, del: false, add: true, edit: true, search: false }, 
      { 
       //Edit mode 
       height: 150, 
       reloadAfterSubmit: true, 
       modal: true, 
       closeOnEscape: true, 
       url: "someURL"     
      }, 
      { //Add mode 
       height: "auto", 
       reloadAfterSubmit: false, 
       modal: true, 
       closeOnEscape: true, 
       url: "someURL",     
       recreateForm: true, 
       //trying to use this because onSelectRow does not fire 
       beforeShowForm: function (form) {      
        var cm = metaGrid.jqGrid('getColProp', 'MetaType');      
        cm.editable = true; 
       } 
      }, 
      {  
       //Delete mode     
      }, 
      { 
      //View mode    
      } 
     ); 

感謝, APPLOADER

+0

我得到了這一個。謝謝! – Apploader 2011-02-12 11:11:31

回答

1

也許你可以刪除這條語句:

onSelectRow: function (id) { 
       alert("Before Iff statement"); 
       if (id && id !== lastSel) { 
        alert("hi, selected"); 
        jQuery(this).restoreRow(lastSel); 
        var cm = metaGrid.jqGrid('getColProp', 'MetaType'); 
        cm.editable = false; 
        //grid.jqGrid('addRow', id, true, null, null, 'someURL'); 
        //cm.editable = true; 
        lastSel = id; 
       } 

,並添加「cellEdit :false「

相關問題