datagrid中的editor,combobox动态添加数据源,实现二级联动的办法(更新中)




但当我结束这一行编辑的时候,显示的不是combobox的text,而是显示的是combobox的value

请问,我该如何处理,才能让结束编辑后,显示的是combobox的text?
求解!各位大仙!
一下是局部代码:
XML/HTML code ?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
< table  id = "detailTable"  style = "width:auto;height:auto"
                         title = "采购明细" >
                     < thead >
                         < tr >
                             < th  data-options="field:'categoryId',width:120,align:'center',
                                     editor:{
                                         type:'combobox',
                                         options:{
                                             valueField:'superId',
                                             textField:'superName',
                                             required:true
                                         }
                                     }">类别
                             </ th >
                             < th  data-options="field:'brandId',width:120,align:'center',
                                     editor:{
                                         type:'combobox',
                                         options:{
                                             valueField:'superId',
                                             textField:'superName',
                                             required:true
                                         }
                                     }">品牌
                             </ th >
                             < th  data-options="field:'productionId',width:120,align:'center',
                                     editor:{
                                         type:'combobox',
                                         options:{
                                             valueField:'id',
                                             textField:'name',
                                             required:true
                                         }
                                     }">产品
                             </ th >
                             < th  data-options="field:'storeId',width:120,align:'center',
                                     editor:{
                                         type:'combobox',
                                         options:{
                                             valueField:'superId',
                                             textField:'superName',
                                             required:true
                                         }
                                     }">仓库
                             </ th >
                             < th  data-options = "field:'price',width:70,align:'center',editor:'numberbox'" >单价</ th >
                             < th  data-options = "field:'count',width:70,align:'center',editor:'numberbox'" >数量</ th >
                             < th  data-options = "field:'total',width:70,align:'center',editor:'numberbox'" >总价</ th >
                             < th  data-options = "field:'prePay',width:70,align:'center',editor:'numberbox'" >预付</ th >
                         </ tr >
                     </ thead >
                 </ table >

JavaScript code ?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
var  lastIndex;
         $( '#detailTable' ).datagrid({
             toolbar:[{
                 text: '新增' ,
                 iconCls: 'icon-add' ,
                 handler: function (){
                     $( '#detailTable' ).datagrid( 'endEdit' , lastIndex);
                     $( '#detailTable' ).datagrid( 'appendRow' ,{
                         categoryId: '' ,
                         brandId: '' ,
                         productionId: '' ,
                         storeId: '' ,
                         price: '' ,
                         count: '' ,
                         total: '' ,
                         prePay: ''
                     });
                     
                     lastIndex = $( '#detailTable' ).datagrid( 'getRows' ).length-1;
                     $( '#detailTable' ).datagrid( 'selectRow' , lastIndex);
                     $( '#detailTable' ).datagrid( 'beginEdit' , lastIndex);
                     
                     synchCategory(getEditRow(lastIndex, 'categoryId' ),lastIndex);
 
                     synchStore(getEditRow(lastIndex, 'storeId' ));
                 }
             }, '-' ,{
                 text: '编辑' ,
                 iconCls: 'icon-remove' ,
                 handler: function (){
                     var  row = $( '#detailTable' ).datagrid( 'getSelected' );
                     if  (row){
                         var  index = $( '#detailTable' ).datagrid( 'getRowIndex' , row);
                         $( '#detailTable' ).datagrid( 'deleteRow' , index);
                     }
                 }
             }, '-' ,{
                 text: '删除' ,
                 iconCls: 'icon-remove' ,
                 handler: function (){
                     var  row = $( '#detailTable' ).datagrid( 'getSelected' );
                     if  (row){
                         var  index = $( '#detailTable' ).datagrid( 'getRowIndex' , row);
                         $( '#detailTable' ).datagrid( 'deleteRow' , index);
                     }
                 }
             }],
             onClickRow: function (rowIndex){
                 if  (lastIndex != rowIndex){
                     $( '#detailTable' ).datagrid( 'endEdit' , lastIndex);
                     $( '#detailTable' ).datagrid( 'beginEdit' , rowIndex);
                 }
                 lastIndex = rowIndex;
             }
         });
 
// 异步加载类别,并在选中后,级联加载品牌(Brand)的combobox
function  synchCategory(editRow,index){
         $(editRow.target).combobox( 'reload' , 'category/findSuperCategoryByAjax.action?date='
                 new  Date().getTime());
         $(editRow.target).combobox({onSelect: function (){
             synchBrand(getEditRow(index, 'brandId' ),index,$( this ).combobox( 'getValue' ));
         }});
     }
 
// 异步加载品牌,并在选中后,级联加载商品(Production)的combobox   
function  synchBrand(editRow,index,categoryId){
         jQuery(editRow.target).combobox( 'reload' , 'brand/findSuperBrandByAjax.action?categoryId='  + categoryId +  '&date='
                 new  Date().getTime());
 
         $(editRow.target).combobox({onSelect: function (){
             synchProduction(getEditRow(index, 'productionId' ),index,$( this ).combobox( 'getValue' );
         }});
}
 
// 加载品牌(production)
function  synchProduction(editRow,index,brandId){
         jQuery(editRow.target).combobox( 'reload' , 'production/findProductionByAjax.action?brandId='  + brandId +  '&date='  new  Date().getTime());
}
 
// 加载仓库   
function  synchStore(editRow){
         jQuery(editRow.target).combobox( 'reload' , 'store/findSuperStoreByAjax.action?date='
                 new  Date().getTime());
}
 
// 获取需要编辑的控件
function  getEditRow(lastIndex,field){
     return  category = jQuery( '#detailTable' ).datagrid( 'getEditor' , {  
         index : lastIndex,  
         field : field
});
}
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值