📄 list1.1.js
字号:
var mode = column.mode;
if(mode==null || mode ==""){
mode = "string";
column.mode = mode;
}
data = oThis.getValueOfCell(rowData,column);
var sb = new Array();
if(mode=="string"){
align = "left";
}else if(mode=="number"){
align = "right";
}else if(mode=="money"){
align = "right";
data = formatToMoney(""+data);
}else if(mode=="check"){
align = "center";
if(data==true){
data = '<div class="checked"></div>';
}else{
data = ' ';
}
}else if(mode=="select"){
align = "center";
var op = getColumnOption(column,data);
if(op!=null){
data = op.name;
}else{
data = " ";
}
}else if(mode=="function"){
align = "left";
}else if(mode=="date"){
align = "center";
data = data.substring(0,10);
}else if(mode=="link"){
if(data!=" "){
data = '<a href="#" onclick="list_onLink(' + oThis.getId() +',' + rowData.l_r_id +',\''+column.name+ '\')">' + data + '</a>'
}
align = "center";
}
if(column.align!=null){
align = column.align;
}
if(data== " "){
data = " ";
}
var width = getColumnWidth(column);
var sb = new Array();
sb[sb.length] = '<td width=' + width;
sb[sb.length] = ' align='+align;
sb[sb.length] = '>' + data;
sb[sb.length] = '</td>';
return sb.join("");
}
this.getPropertyOfObj = function(obj,pName){
if(obj==null){
return null;
}
var name = pName;
var ns = name.split(".");
if(ns[1]=="")
ns.removeAt(1);
if(ns.length>1){
for(var i=0;i<ns.length-1;i++){
var parent = obj;
obj = parent[ns[i]];
if(obj==null){
return null;
}
}
obj = obj[ns[ns.length-1]];
}else{
obj = obj[pName];
}
return obj;
}
this.getValueOfCell = function(rowObj,column) {
var v = oThis.getPropertyOfObj(rowObj,column.name);
if(v==null || v==""){
if(column.mode=="number"){
v = "0.00";
}else if(column.mode=="money"){
v = "0";
}else
v = " ";
}
return v;
}
this.selectAll = function(){
}
this.onSelect = function(){
}
this.getRow = function(rowId){
if(oThis.rows[rowId]==null){
var row = new SigmaListRow(oThis,rowId);
oThis.rows[rowId] = row;
return row;
}else
return oThis.rows[rowId];
}
var colResize = oThis.element.all("colResize");
var headerArea = oThis.element.all("headTable");
var rs_start = 0;
var start_width = 0;
var nextColStartWidth = 0;
this.debugCanvas = null;
this.debug = function(s){
if(oThis.debugCanvas!=null){
oThis.debugCanvas.innerText = oThis.debugCanvas.innerText + "\n" + s;
}
}
this.setColumnWidth = function(column,newWidth){
column.width = newWidth;
oThis.debug("set column name,column:" + column.name + ",width:" + column.width);
oThis.columnHeaders[column.name].style.width = newWidth;
var rows = oThis.element.all("dataTable").rows;
if(rows.length>0){
var cIndex = oThis.columns.indexOf(column);
if(oThis.context.sequence==true)
cIndex++;
if(oThis.context.checkBox==true)
cIndex++;
else if(oThis.context.radioBox==true)
cIndex++;
for(var i=0;i<rows.length;i++){
var row = rows[i];
var cell = row.cells[cIndex];
cell.style.width = newWidth;
}
}
}
headerArea.onmousemove = function(){
var cell = oThis.findResizingCell();
if(cell!=null){
offset = event.clientX - rs_start;
var newWidth = start_width + offset;
if(newWidth<5){
newWidth = 5;
offset = newWidth - start_width;
}
oThis.setColumnWidth(cell.column,newWidth);
if(offset<0){
var column = oThis.getNextColumn(cell.column);
if(column!=null){
var nextColWidth = nextColStartWidth - offset;
oThis.setColumnWidth(column,nextColWidth);
}
}
return;
}
var src = window.event.srcElement;
if(src.column!=null){
if(src.resizing==null || src.resizing==false){
if(src.offsetWidth - event.offsetX<=3){
oThis.element.style.cursor = "E-resize";
}else{
oThis.element.style.cursor = "";
}
}
}
}
headerArea.onmousedown = function(){
var src = window.event.srcElement;
if(src.column!=null){
if(src.offsetWidth - event.offsetX<=3){
src.resizing = true;
rs_start = event.clientX;
oThis.beginResizeColumn(src);
}
}
}
headerArea.onmouseup = function(){
var src = window.event.srcElement;
if(src.column!=null){
src.resizing = false;
}
}
headerArea.onmouseout = function(){
var cell = oThis.findResizingCell();
if(cell==null){
oThis.element.style.cursor = "";
}
}
this.findResizingCell = function(){
var headTable = oThis.element.all("headTable");
var cells = headTable.rows[0].cells;
for(var i=0;i<cells.length;i++){
var cell = cells[i];
if(cell.resizing == true){
return cell;
}
}
return null;
}
this.beginResizeColumn = function(cell){
start_width = cell.offsetWidth;
var nextColumn = oThis.getNextColumn(cell.column);
nextColStartWidth = getColumnWidth(nextColumn);
if(nextColumn!=null)
oThis.debug("begin resize:" + cell.column.name + "'s width="+cell.offsetWidth+"; "+nextColumn.name+"'s width="+nextColStartWidth);
else{
oThis.debug("begin resize:" + cell.column.name + "'s width="+cell.offsetWidth+";");
}
}
this.getNextColumn = function(column){
var columns = oThis.columns;
var i = columns.indexOf(column);
i++;
if(i<columns.length){
return columns[i];
}else
return null;
}
this.getColumnLeft = function(column){
var headTable = oThis.element.all("headTable");
var cells = headTable.rows[0].cells;
var left = 0;
var cIndex = oThis.columns.indexOf(column);
for(var i=0;i<cIndex;i++){
var cell = cells[i];
left += cell.offsetWidth;
}
return left;
}
this.getColumnByName = function(colName){
var columns = oThis.columns;
for(var i=0;i<columns.length;i++){
var c = columns[i];
if(c.name == colName){
return c;
}
}
return null;
}
}
function list_onLink(listId,rowId,colName){
var list = getFromContainer(listId);
var event = new Object();
var column = list.getColumnByName(colName);
var row = list.getRow(rowId);
var cell = row.cells[colName];
event.type = "onLink";
event.cell = cell;
eval(column.href+"(event)");
}
function list_onCheckBoxClicked(listId,rowId,checked){
var list = getFromContainer(listId);
var row = list.getRow(rowId);
row.setSelected(checked);
}
function createEmptyTable(rows,columns){
var sb = [];
sb[sb.length] = '<table id="dataTable" border=0 cellspacing=0 cellpadding=0 style="table-layout:fixed">';
for(var i=0;i<rows;i++){
sb[sb.length] = createEmptyRow(columns);
}
sb[sb.length] = "</table>";
return sb.join("");
}
function getColumnOption(column,id){
var options = column.options;
for(var i=0;i<options.length;i++){
var op = options[i];
if(op.id == id){
return op;
}
}
return null;
}
function getColumnWidth(column){
if(column==null)
return 0;
if(column.width == null){
return "";
}else{
return parseInt(column.width);
}
}
function createEmptyRow(columns){
var sb = new Array();
sb[sb.length] = "<tr>";
for(var i=0;i<columns;i++){
sb[sb.length] = '<td> </td>';
}
sb[sb.length] = "</tr>";
return sb.join("");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -