CNSDataGrid.prototype.getDisplay=function(){
return this.table;
};
CNSDataGrid.prototype.clearData=function(){
while(this.tbody.rows.length>0){
this.tbody.deleteRow(-1);
}
};
CNSDataGrid.prototype.clearCustomHeader=function(){
if(this.customHeader){
this.thead.deleteRow(0);
this.customHeader=null;
}
};
CNSDataGrid.prototype.setCustomHeader=function(_1){
this.clearCustomHeader();
this.customHeader=this.thead.insertRow(0);
this.customHeader.className="tablehead";
this.customHeaderTd=this.customHeader.insertCell(0);
this.customHeaderTd.colSpan=this.Columns.arr.length;
this.customHeaderTd.appendChild(document.createTextNode(_1));
this.customHeader.appendChild(this.customHeaderTd);
};
CNSDataGrid.prototype.getCheckboxes=function(){
return false;
};
CNSDataGrid.prototype.setCheckboxes=function(_2){
};
CNSDataGrid.prototype.clearColumns=function(){
while(this.table.rows.length>0){
this.table.deleteRow(-1);
}
};
CNSDataGrid.prototype.renderColumns=function(){
this.clearColumns();
columnRow=this.thead.insertRow(-1);
columnRow.className="tabledivider";
for(i=0;i<this.Columns.arr.length;i++){
currColumn=this.Columns.arr[i];
headCol=document.createElement("th");
if(currColumn.HeaderClass){
headCol.className=currColumn.HeaderClass;
}
headCol.appendChild(document.createTextNode(this.Columns.arr[i].Name));
columnRow.appendChild(headCol);
}
};
CNSDataGrid.prototype.bind=function(_3){
trace("Binding datagrid");
this.clearData();
this.dataSource=_3;
isEven=false;
if(this.dataSource!=null){
for(i=0;i<this.dataSource.length;i++){
isEven=!isEven;
bodyRow=this.tbody.insertRow(-1);
bodyRow.className=isEven?"tablefg":"tablefg2";
for(j=0;j<this.Columns.arr.length;j++){
data=this.dataSource[i];
currColumn=this.Columns.arr[j];
bodyCell=bodyRow.insertCell(-1);
if(currColumn.ItemClass){
bodyCell.className=currColumn.ItemClass;
}
bodyCell.appendChild(this.Columns.arr[j].getDisplay(data));
}
}
}
};
function CNSDataGrid(){
trace("DataGrid Init");
var me=this;
this.table=document.createElement("table");
this.thead=this.table.createTHead();
this.tbody=document.createElement("tbody");
this.table.appendChild(this.tbody);
this.Columns=new DataGridColumns();
this.Columns.OnColumnsChanged=function(){
me.renderColumns();
};
}
function DataGridColumn(_5,_6,_7,_8,_9){
this.Name=_5;
this.BindingExpr=_6;
if(_7){
this.HeaderClass=_7;
}
if(_8){
this.ItemClass=_8;
}
if(_9){
this.AlternatingItemClass=_9;
}
}
DataGridColumn.prototype.getDisplay=function(_a){
if(typeof (this.BindingExpr)=="function"){
return document.createTextNode(this.BindingExpr(_a));
}else{
return document.createTextNode(eval(this.BindingExpr));
}
};
function DataGridLinkColumn(_b,_c,_d,_e,_f,_10,_11){
this.Name=_b;
this.LabelExpr=_c;
this.LinkExpr=_d;
if(_e){
this.HeaderClass=_e;
}
if(_f){
this.ItemClass=_f;
}
if(_10){
this.AlternatingItemClass=_10;
}
if(_11){
this.ClickFunction=_11;
}
}
DataGridLinkColumn.prototype.getDisplay=function(_12){
thisColumn=this;
link=document.createElement("a");
if(typeof (this.LabelExpr)=="function"){
link.appendChild(document.createTextNode(this.LabelExpr(_12)));
}else{
link.appendChild(document.createTextNode(eval(this.LabelExpr)));
}
if(typeof (this.LinkExpr)=="function"){
link.href=this.LinkExpr(_12);
}else{
link.href=eval(this.LinkExpr);
}
link.onclick=function(){
if(thisColumn.ClickFunction){
thisColumn.ClickFunction(_12);
return false;
}
};
return link;
};
function DataGridButtonColumn(_13,_14,_15,_16,_17,_18){
this.Name=_13;
this.LabelExpr=_14;
this.ClickFunction=_15;
if(_16){
this.HeaderClass=_16;
}
if(_17){
this.ItemClass=_17;
}
if(_18){
this.AlternatingItemClass=_18;
}
}
DataGridButtonColumn.prototype.getDisplay=function(_19){
try{
thisColumn=this;
button=document.createElement("button");
if(typeof (this.LabelExpr)=="function"){
button.appendChild(document.createTextNode(this.LabelExpr(_19)));
}else{
button.appendChild(document.createTextNode(eval(this.LabelExpr)));
}
button.onclick=function(){
thisColumn.ClickFunction(_19);
return false;
};
return button;
}
catch(ex){
for(varname in ex){
trace("ex."+varname+" = "+ex[varname]);
}
}
};
DataGridColumns.prototype=new Array;
function DataGridColumns(){
var me=this;
this.arr=new Array();
}
DataGridColumns.prototype.Add=function(_1b){
this.arr.push(_1b);
if(this.OnColumnsChanged!=null){
this.OnColumnsChanged();
}
};
function trace(msg){
if(typeof (jsTrace)!="undefined"){
jsTrace.send(msg);
}
}

