table表格清册获取tr中td的修改事件
$("#tableid").find("tbody td.tdclass").find("input").each(function(){
			$(this).unbind("change").change(function(){
				var datas = getDataFromRow($("#tableid"), $(this).closest("tr"));
			});
		});
getDataFromRow = function($tableid, tr) {
			var columns = getColumns($tableid);
			var data = {};
			var tds = tr.find("td");
			for (var index = 0; index < columns.length; index++) {
				var col = columns[index];
				if (col[0] != "checkbox" && col[0] != "radio"){
					if($(tds[index]).find("input").length==1){
						data[col[0]] = $(tds[index]).find("input").val();
					}else if($(tds[index]).find("select").length==1){
						data[col[0]] = $(tds[index]).find("select").val();
					}else{
						data[col[0]] = $(tds[index]).text();
					}
				}
			}
			return data;
		};
getColumns = function($tableid, resultdata) {
			var columns = [];
			var ths = $tableid.find("thead tr th");
			for (var index = 0; index < ths.length; index++) {
				var th = ths[index];
				columns.push([ $(th).attr("title"), $(th).attr("hidden") || "" ]);
			}
			return columns;

		};



$("#tableid").find("tbody td.tdclass")..find("input").each(function(){
			$(this).unbind("change").change(function(){
				var datas = shineyue.getDataFromRow(shineyue.find("tableid"), $(this).closest("tr"));
			});
		});
		getDataFromRow = function($tableid, tr) {
			var columns = getColumns($grid);
			var data = {};
			var tds = tr.find("td");
			for (var index = 0; index < columns.length; index++) {
				var col = columns[index];
				if (col[0] != "checkbox" && col[0] != "radio"){
					if($(tds[index]).find("input").length==1){
						data[col[0]] = $(tds[index]).find("input").val();
					}else if($(tds[index]).find("select").length==1){
						data[col[0]] = $(tds[index]).find("select").val();
					}else{
						data[col[0]] = $(tds[index]).text();
					}
				}
			}
			return data;
		};
		getColumns = function($grid, resultdata) {
			var columns = [];
			var ths = $grid.find("thead tr th");
			for (var index = 0; index < ths.length; index++) {
				var th = ths[index];
				columns.push([ $(th).attr("title"), $(th).attr("hidden") || "" ]);
			}
			return columns;

		};

阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

table表格清册获取tr中td的修改事件

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭