1.获取下拉框的需要的数据
1 var sddata = {$sddata};
2 var sddataID = [];
3 var sddatafirst = ‘‘;
4 for(var i=0;i<sddata.length;i++){
5 if(!sddatafirst) sddatafirst =sddata[i].sdid;
6 sddataID[sddata[i].sdid] = sddata[i].sdname;
7 }
2.datagrid 属性渲染字段
1 CONFIG.WINCOLUMNSS =[[
2 {title:‘订单原金额‘,colspan:2, align:"right"},
3 {field:‘sum‘,id:‘price‘,colspan:2, align:"center"},
4 {title:‘验货金额‘,colspan:2,align:"center"},
5 {id:‘sprice‘,colspan:3,align:"right" }
6 ],[
7 {
8 id : "check",
9 field:"ck",
10 checkbox:true,
11 },
12 {
13 field : ‘code‘,
14 title : ‘{:L("原材料编号")}‘,
15 width : ‘10%‘,
16 }, {
17 field : ‘mgname‘,
18 title : ‘{:L("原材料名称")}‘,
19 width : ‘15%‘,
20 },{
21 field : ‘sdid‘,
22 title : ‘{:L("仓库")}‘,
23 width : ‘20%‘,
24 formatter:function(value,row){
25 if(row.sdid ==‘‘){
26 return ‘请选择仓库‘;
27 }
28 return sddataID[value]
29 },editor:{
30 type: ‘combobox‘,
31 options:
32 {
33 valueField: "sdid",
34 textField: "sdname",
35 editable : false,
36 data: sddata
37 }
38 }
39 },{
40 field : ‘oprice‘,
41 title : ‘{:L("单价")}‘,
42 width : ‘10%‘,
43 }, {
44 field : ‘goodsno‘,
45 title : ‘{:L("订购数量")}‘,
46 width : ‘10%‘,
47 }, {
48 field : ‘tprice‘,
49 title : ‘{:L("金额")}‘,
50 width : ‘10%‘,
51 },{
52 field : ‘qgoodsno‘,
53 title : ‘{:L("实到数量")}‘,
54 width : ‘20%‘,
55 editor:{type:‘numberbox‘,
56 options:{
57 min:0,
58 required:true
59 }}
60 }, {
61 field : ‘remarks‘,
62 title : ‘{:L("备注")}‘,
63 width : ‘20%‘,
64 editor:{type:‘textbox‘}
65 }]];
3.加载编辑事件(加载一行的所有编辑框)
1 objs.wingrids=$(‘#wingrids‘).datagrid({
2 nowrap:true,
3 fit : true,
4 border : false,
5 striped : true,
6 toolbar : ‘#wingridToolbars‘,
7 loadMsg : ‘{:L("正在加载数据,请稍后...")}‘,
8 rownumbers : true,
9 columns:CONFIG.WINCOLUMNSS,
10 onSelect:loadvprice,
11 onClickRow: onClickRow,
12 });
4.可编辑 js
1 /* 启用可编辑表格*/
2 var editIndex = undefined;
3 function onClickRow(index){
4 if (editIndex == index)return false;
5 if (endEditing()){
6 objs.wingrids.datagrid(‘selectRow‘, index).datagrid(‘beginEdit‘, index);
7 editIndex = index;
8 } else {
9 objs.wingrids.datagrid(‘selectRow‘, editIndex);
10 }
11 }
12
13 /* 完成可编辑*/
14 function endEditing(){
15 if(editIndex == undefined){return true;}
16 if(objs.wingrids.datagrid(‘validateRow‘, editIndex)){
17 objs.wingrids.datagrid(‘endEdit‘, editIndex);
18 editIndex = undefined;
19 return true;
20 }else {
21 return false;
22 }
23 }