1. 程式人生 > >easyui 追加文本框 數字框 及下拉框

easyui 追加文本框 數字框 及下拉框

sel nss font obj option ++ pos ... min

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         }

easyui 追加文本框 數字框 及下拉框