Flexigrid的编辑功能

editCells:function(){
				if(!isEditing){
					isEditing = true;
					$('tbody tr',$(t)).each(function () {
	    			for(var i=0;i<this.cells.length;i++){
	    				  var td = this.cells[i];
	    				  if(p.colModel[i].isEdit){
	    				  	  var div = $('div',$(td));
										div[0].innerHTML = '<input type="text" style="width:' + (p.colModel[i].width-2) + 'px" value="'+div[0].innerHTML+'"/>';
								}
	    			}
	    		});
    	  }
			},
			commitCells:function(){
				if(!isEditing) return;
				$('tbody tr',$(t)).each(function() {
    			for(var i=0;i<this.cells.length;i++){
    				  var td = this.cells[i];
    				  if(p.colModel[i].isEdit){
    				  	  var div = $('div',$(td));
    				  	  var inputbox = $('input',$(div[0]));
    				  	  if(inputbox.length>0){
										div[0].innerHTML = inputbox[0].value;
								  }
							}
    			}
    		});
    		isEditing = false;
			}

效果如下图


该章节不贴全部代码了,详细代码可以参见前面博文的介绍

你可能感兴趣的:(input,flexigrid,编辑)