0

我是首發中jqGrid的,我想實現在線編輯和編寫代碼:得到單選按鈕值的jqGrid

var gridDocument = jQuery("#listDocument"); 
      gridDocument.jqGrid({ 
       url: 'jQGridHandler.ashx', 
       postData: { ActionPage: 'ClearanceRequestDocument', Action: 'Fill', RequestId: '3' }, 
       ajaxGridOptions: { cache: false }, 
       loadonce: true, 
       direction: "rtl", 
       datatype: 'json', 
       height: '490', 
       colNames: ['DocumentNO', 'Documentname', 'OrginalCertificate', ' CopyCertificate', 'Remark'], 
       colModel: [ 
         { name: 'DOCUMENT_ID', width: 200, sortable: true, hidden: true }, 
         { name: 'DOCUMENT_NAME', width: 200, sortable: true, editable: false }, 
        { 
         name: 'Orignal', width: 80, fixed: true, align: 'center', resizable: false, sortable: false, 
         formatter: function (cellValue, option, rowObject) { 
          return '<input id="t2" type="radio" name="radio_' + rowObject + '" />'; 
         } 
        }, 
         { 
          name: 'Copy', width: 80, fixed: true, align: 'center', resizable: false, sortable: false, 
          formatter: function (cellValue, option, rowObject) { 
           return '<input id="t1" type="radio" name="radio_' + rowObject + '" />'; 
          } 
         }, 
        // { name: 'is_ORGINAL', width: 80, sortable: true, editable: true, formatter: 'checkbox', edittype: 'checkbox', editoptions: { value: 'Yes:No', defaultValue: 'Yes'} }, 
         //{ name: 'is_copy', width: 80, sortable: true, editable: true, formatter: 'checkbox', edittype: 'checkbox', editoptions: { value: 'Yes:No', defaultValue: 'Yes'} }, 
         { name: 'REMARK', width: 200, sortable: true, editable: false } 
       ], 

       sortname: 'DOCUMENT_ID', 
       viewrecords: true, 
       rownumbers: true, 
       sortorder: "desc", 
       editurl: 'clientArray', 
       altRows: true, 
       altclass: 'ui-priority-secondary', 
       onSelectRow: function (id) { 
        if (id && id !== lastSel) { 
         gridDocument.saveRow(lastSel, true, 'clientArray'); 
         gridDocument.jqGrid('restoreRow', lastSel); 
         gridDocument.jqGrid('editRow', id, true, null, null, 'clientArray'); 
         lastSel = id; 
         intArray[index] = id; 
         index += 1; 
        } 
       }, 
       pager: '#pagerDocument', 
       rowNum: 30, 
       rowList: [30, 60, 90], 

       loadComplete: function() { 
        var $this = $(this), ids = $this.jqGrid('getDataIDs'), i, l = ids.length; 
        for (i = 0; i < l; i++) { 
         $this.jqGrid('editRow', ids[i], true); 
        } 
       } 
      }).jqGrid('navGrid', '#pagerDocument', { edit: false, add: false, del: false, search: false, refresh: false }); 

我這個網我有2個單選按鈕欄。我想用戶確定提出這個cetificate證據是否是原單或複製我試圖通過這個代碼(選中或unchacked)

for (var i = 0; i < $("#listDocument").getGridParam("reccount") ; i++) { 
              var row = $("#listDocument").jqGrid('getRowData', i + 1); 
        alert($(row.Orignal).is(":checked") + "|" + row.Copy); 

       } 

這個代碼時刻警惕假值,請幫我寫這段代碼獲得價值單選按鈕,謝謝所有專家。

回答

0

如果你想檢查的單選按鈕按原價(true或false)

變化格式化功能從

     formatter: function (cellValue, option, rowObject) { 
         return '<input id="t2" type="radio" name="radio_' + rowObject + '" />'; 
        } 

     formatter: function (cellValue, option, rowObject) { 
         return '<input id="t2" type="radio" name="radio_' + rowObject["DOCUMENT_ID"] + '" checked="'+cellvalue+'"/>'; 
        } 

我不明白的價值爲什麼要將名稱追加到rowobject上

UPDATE:

我以爲你想檢查負載上的單選按鈕。如果要確保在內聯編輯時僅檢查單選按鈕,則可以使用自定義驗證。

使用自定義功能來驗證原件及複印件(使用相同的功能都列)

use editrules:{custom: true, custom_func: validateOriginalOrCopy} 

在custom_func有2個參數傳遞價值和COLNAME你可以用這些參數來驗證

+0

我想在每一行只檢查一個單選按鈕。 –

+0

查看已更新的答案 – Kris

+0

in validateOriginalOrCopy function 如何查看例如,單擊複印單選按鈕時首先應檢查用戶 已選擇原始或否, –