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 如何查看例如,单击复印单选按钮时首先应检查用户 已选择原始或否, –