定义:
01 | $.extend($.fn.datagrid.defaults.editors, { |
02 | combogrid: { |
03 | init: function (container, options){ |
04 | var input = $( '<input type="text" class="datagrid-editable-input">' ).appendTo(container); |
05 | input.combogrid(options); |
06 | return input; |
07 | }, |
08 | destroy: function (target){ |
09 | $(target).combogrid( 'destroy' ); |
10 | }, |
11 | getValue: function (target){ |
12 | return $(target).combogrid( 'getValue' ); |
13 | }, |
14 | setValue: function (target, value){ |
15 | $(target).combogrid( 'setValue' , value); |
16 | }, |
17 | resize: function (target, width){ |
18 | $(target).combogrid( 'resize' ,width); |
19 | } |
20 | } |
21 | }); |
用法:
01 | $( '#dg' ).datagrid({ |
02 | columns:[[ |
03 | {field: 'productid' ,name: 'ProductId' ,width:100, |
04 | editor:{ |
05 | type: 'combogrid' , |
06 | options:{ |
07 | panelWidth:450, |
08 | idField: 'code' , |
09 | textField: 'name' , |
10 | url: 'datagrid_data.json' , |
11 | columns:[[ |
12 | {field: 'code' ,title: 'Code' ,width:60}, |
13 | {field: 'name' ,title: 'Name' ,width:100}, |
14 | {field: 'addr' ,title: 'Address' ,width:120}, |
15 | {field: 'col4' ,title: 'Col41' ,width:100} |
16 | ]] |
17 | } |
18 | } |
19 | } |
20 | ]] |
21 | }); |