1

編集できない行がほとんどないjqgridがあります。私の問題は、編集できない行の前にあるチェックボックスを無効にしたいことです。現在、行データを編集不可にすることはできますが、前のチェックボックスは無効になっておらず、クリックして選択できます

私のコードは以下のとおりです。JSONを使用してデータを渡しています:

コード内では、これらの行を使用して行を無効にします。一部の行には JSON 'ReadOnly' を渡します。jqgrid の完全なコードは次のとおりです。

beforeSelectRow: function(rowid, e) {
            var grid = $('#list4');
            var data = grid.getRowData(rowid);
            if (data.accessType == 'ReadOnly') { 
                 $(#id).attr('disabled', true);
                 return false;
            }else{
                return true;
            }


var dateoflaunchTxt = 'The launch date of a project refers to the first day when units are made available to prospective home-buyers (i.e. issue of the Option-to-Purchase) including private previews or any other occasion which may take place before the official launch of the project.';
var grid = $("#list4");
grid.jqGrid({
datastr: <%=jsonGridData%>,
datatype: "jsonstring",
height: 400,
    colNames:['S No','Date of Launch','No of Units','Access Type'],
    colModel:[
           {name:'id',index:'id', width:40,align:"center", sorttype:"int"},
           {name:'dateofLaunch',index:'dateofLaunch',align:"center", width:75, sorttype:"date",sortable:true
            ,editable:true , editoptions: {
                        dataInit: function (element) {
                            $(element).datepicker({
                                dateFormat:"dd/mm/yy",
                                onSelect: function(dateText, inst) { 
                                     var $input = inst.input; // the datepicker input
                                     var $row = $input.parents("tr"); 
                                     $("#list4").jqGrid('saveRow',$row.attr("id"), false);
                                     }
                                });

                        }
                    }},
           {name:'noOfUnits',index:'noOfUnits', align:"center",width:40, sorttype:"integer",sortable:true,editable:true},
           {name:'accessType',index:'accessType', align:"center",width:40, sortable:false,editable:false}
    ],
        jsonReader : {
          root: "rows",
          page: "page",
          total: "total",
          records: "records",
          repeatitems: true,
          cell: "cell",
          id: "id"
    },
        editurl: "clientArray",
        multiselect: true,
        pagination:true,
        pager: '#search',
        rowNum: 15,
        rowList: [5,10,15,30,45,60],
        sortname: 'id',   
        sortorder: 'asc',
        sortable:true,
        viewrecords: true,
        loadonce: true,  
        pgtext : "Page {0} of {1}",
        emptyrecords:'No Records',
        loadtext:'Loading ...',
        showpage:true,   
        caption: "Launch Info",
        headertitles: true,
        cellEdit: true,
        cellsubmit: 'clientArray',
        beforeSelectRow: function(rowid, e) {
            var grid = $('#list4');
            var data = grid.getRowData(rowid);
            if (data.accessType == 'ReadOnly') { 
                 $(#id).attr('disabled', true);
                 return false;
            }else{
                return true;
            }
        },              
        loadComplete: function(){gridComplete();
        }

}).jqGrid('navGrid','#pager',
          {edit:false, add:false, del:false, search:false, refresh:true});
grid.setLabel ('dateofLaunch','','',{'title':dateoflaunchTxt});

jQuery("#list4").hideCol("id");
jQuery("#list4").hideCol("accessType");
$("#list4").jqGrid('setGridState','hidden');
$("#list4").jqGrid('setGridState','visible');
//$('#list4').setGridParam({sortname:'id'}).trigger('reloadGrid');
jQuery("#list4").setGridWidth(500);

function pickdates(id){
    jQuery("#"+id+"_dateofLaunch","#list4").datepicker({dateFormat:"dd-mm-yy", constrainInput: true});
}

画像 :編集不可の行を選択しました。チェックボックスをオンにできますが、行が強調表示されません。編集可能な行の場合は強調表示されます。

編集不可の行を選択しました。チェックボックスをオンにできますが、行が強調表示されていません。編集可能な行の場合は強調表示されます

ここに画像の説明を入力

私が望むのは、すべての編集不可能な行の前からこのチェックボックスを無効にすることであり、編集可能なユニットに対して有効にする必要があります

ありがとう

4

2 に答える 2

0

こんにちは、jqGrid 'multiselect' を使用しないでください。以下のように独自の列を追加してください

  {name:'my_clickable_checkbox',index:'my_clickable_checkbox',formatter: "checkbox", formatoptions: {disabled : false}},

onGridComplete:function(){
     //here enable or disable 'my_clickable_checkbox' column based on your condition
}
于 2013-08-13T12:41:16.897 に答える
0

jqgrid にもう 1 列追加 (非表示に設定) この非表示フィールドの値は、JQ グリッドの JSON 配列データを作成するときに計算されました。この非表示の列の値に基づいて、JQgrid の読み込み中に行を編集可能または編集不可に設定します。

于 2014-06-14T02:23:37.307 に答える