easyui就地编辑


easyui就地编辑
查找相关文章:easyui editor

双击显示text文本框,enter保存,也可以做成blur

$.extend($.fn.datagrid.defaults.editors, {
		person_in_charge: {
			init: function(container, options){
				var row = container.closest('tr.datagrid-row');
				
				var value='';
				if(current_row.hasOwnProperty('person_in_charge')){
					if(current_row.person_in_charge == null){
						value = '';
					}else{
						value = current_row.person_in_charge;
					}					
				}
								
				var input = $('<input type="text" class="datagrid-editable-input" value="'+value+'">').appendTo(container);
				
				// input.blur();
				input.keypress(function(event) {
			        if (event.keyCode == 13) {			        	
			        	var row = container.closest('tr.datagrid-row');
					//ajax自行处理
			        }
			    });
				
				return input;
			},
	        destroy: function(target){
	            $(target).remove();
	        },
	        getValue: function(target){
	            return $(target).val();
	        },
	        setValue: function(target, value){
	            $(target).val(value);
	        },
	        resize: function(target, width){
	            $(target)._outerWidth(width);
	        }
		}
	});


双击的时候设置为可编辑

onDblClickCell:function(index,field,value){
        	//取消其他的可编辑
		var note_col = _grid.datagrid('getColumnOption', 'note');
		var person_in_charge_col = _grid.datagrid('getColumnOption', 'person_in_charge');
			
        	if(field == 'person_in_charge'){
        		var col = _grid.datagrid('getColumnOption', field);
        		person_in_charge_col.editor = {type:'person_in_charge'};
        		note_col.editor = null;
        		_grid.datagrid('beginEdit', index);
        		
        	}
        },