Dorado页面中点击表格中的记录时当前行自动调整行高,换行显示隐藏的信息

/**
 * 点击表格条目时,当前行换行显示隐藏的信息
 * id:DataGrid的id属性字符串
 */
function DoradoTools_showGridDetail(self) {
	var id = 'd_' + self.get('id');
	var filterOther = "#" + id + " tr.row:not('.current-row') td:not('.header') div";
	var filterCurrent = "#" + id + " tr.current-row td div[class='cell']";
	// for browser IE
	if ($.browser.msie) {
		var $oddDivs = $(filterOther);
		var oddDivsSize = $oddDivs.size();
		if (oddDivsSize != 0) {
			for (var i = 0; i < oddDivsSize; i++) {
				var css = $oddDivs[i].style.cssText;
				var cssNew = css;
				if (css.indexOf() != -1) {
					cssNew = css.replace("-ms-word-wrap: break-word;", "");
				}
				if (css.indexOf() != -1) {
					cssNew = css.replace("-ms-word-break: break-all;", "");
				}
				if (css.indexOf("white-space: normal;") != -1) {
					cssNew = css.replace("normal", "nowrap");
				}
				$oddDivs[i].style.cssText = cssNew;
			}
		}
		var $currentDivs = $(filterCurrent);
		var size = $currentDivs.size();
		for (var i = 0; i < size; i++) {
			$currentDivs[i].style.cssText = $currentDivs[i].style.cssText
					+ "white-space:normal;word-wrap: break-word; word-break: break-all;";
		}
		self.refreshDom(self.getDom());
	} else {// for browsers google chorme and FireFox. 
		var $oddDivs = $(filterOther);
		var oddDivsSize = $oddDivs.size();
		if (oddDivsSize != 0) {
			for (var i = 0; i < oddDivsSize; i++) {
				var css = $oddDivs[i].style.cssText;
				var cssNew = css;
				if (css.indexOf("white-space: normal;") != -1) {
					cssNew = css.replace("normal", "nowrap");
				}
				$oddDivs[i].style = cssNew;
			}
		}
		var $currentDivs = $(filterCurrent);
		var size = $currentDivs.size();
		for (var i = 0; i < size; i++) {
			$currentDivs[i].style = $currentDivs[i].style.cssText + "white-space:normal;word-wrap: break-word; word-break: normal;";
		}
		self.refreshDom(self.getDom());
	}
}

在使用该函数时要打开表格的自动行高属性,DataGrid>dynaRowHeight=true;将上面的函数封装到公用js文件中,或是放在当前文件中。

函数调用: DoradoTools_showGridDetail(self);这句代码放在表格的onDataRowClick事件中。



你可能感兴趣的:(Dorado页面中点击表格中的记录时当前行自动调整行高,换行显示隐藏的信息)