问题描述
$(function(){$('#purchase_arrival_form').datagrid({fit:false,//控件自动resize占满窗口大小iconCls:'icon-save',//图标样式barrival:true,//是否存在边框fitColumns:false,//自动填充行nowrap:true,//禁止单元格中的文字自动换行loadMsg:'',autoRowHeight:false,//禁止设置自动行高以适应内容striped:true,//true就是把行条纹化。(即奇偶行使用不同背景色)singleSelect:true,//限制单选checkOnSelect:false,//选择复选框的时候选择该行selectOnCheck:false,//选择的时候复选框打勾url:ctx+'/do/purchaseArrivalDetail/list.json?purArrivalId=${purchaseDate.purArrivalId}',sortName:'goodsCode',//排序字段名称sortOrder:'DESC',//升序还是降序remoteSort:true,//开启远程排序,默认为falseidField:'purOrderDetId',columns:[[{field:'goodsCode',title:'货品编码',width:100,editor:{type:'text',required:true}},{field:'goodsName',title:'货品名称',width:100},{field:'goodsId',title:'货品编号',width:100,hidden:true},{field:'placeOfOrigin',title:'产地',width:100,hidden:true},{field:'goodsModel',title:'规格型号',width:100},{field:'goodsUnit',title:'单位',width:100},{field:'batchInformation',title:'批次信息',width:100,editor:{type:'text'}},{field:'arrival',title:'到货数量',width:100,editor:{type:'numberbox',options:{required:true,onChange:function(rec){varindexRows=getRowIndex(this);//到货数量arrivalChange(indexRows,rec);}}}},{field:'delivery',title:'收货数量',width:100,editor:{type:'numberbox',options:{required:true,onChange:function(rec){varindexRows=getRowIndex(this);//到货数量deliveryChange(indexRows,rec);}}}},{field:'rejection',title:'拒收数量',width:100,editor:{type:'numberbox',options:{required:true,onChange:function(rec){varindexRows=getRowIndex(this);//拒收数量rejectionChange(indexRows,rec);}}}},{field:'originalCost',title:'原价',width:100},{field:'depositRate',title:'折扣率',width:100,editor:{type:'numberbox',options:{required:true,precision:2,onChange:function(rec){varindexRows=getRowIndex(this);//折扣率数量depositRateChange(indexRows,rec);}}}},{field:'price',title:'单价',width:100,editor:{type:'numberbox',options:{required:true,precision:2,onChange:function(rec){varindexRows=getRowIndex(this);//折扣率priceChange(indexRows,rec);}}}},{field:'goodsMoney',title:'总金额',width:100,editor:{type:'numberbox',options:{required:true,precision:2,onChange:function(rec){varindexRows=getRowIndex(this);//总金额goodsMoneyChange(indexRows,rec);}}}},{field:'cess',title:'税率',width:100,hidden:true,editor:{type:'numberbox',options:{required:true,precision:2}}},{field:'deadline',title:'交货期限',width:100,editor:{type:'datebox',options:{}}},{field:'remark',title:'备注',width:100,editor:{type:'text'}}]],onLoadSuccess:function(data){console.log(data.rows.length);for(vari=0;i<data.rows.length;i++){//这里循环就为空了$('#purchase_arrival_form').datagrid("beginEdit",i);}},toolbar:[{text:'添加商品',iconCls:'icon-standard-pencil-add',handler:function(){varrows=$('#purchase_arrival_form').datagrid("getRows");for(vari=0;i<rows.length;i++){//这里循环为空了,这里也一样$('#purchase_arrival_form').datagrid("beginEdit",i);}}},{text:'删除商品',iconCls:'icon-standard-pencil-delete',handler:function(){$.messager.confirm('提示','确认删除数据?',function(r){if(r){varrows=$('#purchase_arrival_form').datagrid("getSelected");varrow=$('#purchase_arrival_form').datagrid('getRowIndex',rows);$('#purchase_arrival_form').datagrid('deleteRow',row);compute();}});}},{text:'批量添加商品',iconCls:'icon-standard-pencil-add',handler:function(){batchRows();}}]});});//有3条数据,想在onLoadSuccess里面数据加载完毕了然后循环自动开启编辑框editor,却报TypeError:$(...).datagrid(...)isnull
解决方案
本帖最后由 wuting0759 于 2015-01-31 14:14:09 编辑