Click here to Skip to main content
15,885,309 members
Articles / Web Development / ASP.NET

SDXGrid V1.0.1.5 (VS 2005)

Rate me:
Please Sign up or sign in to vote.
4.71/5 (41 votes)
14 Jun 20074 min read 88.7K   3.2K   82  
SDXGrid, is a comprehensive data grid component for Microsoft .NET 2.0 web application developers, easing the exhausting process of implementing the necessary code for sorting, navigation, grouping, searching, and real time data editing in a simple data representation object.
function SDX_RowView(_ID, _Data, _RootObject)
{
 this.RootObject = _RootObject ;
 this.ID=_ID ;
 this.HTMLID = "SDXRow_" + this.RootObject.Name + "_" + _ID ;
 this.SelectionTDHTMLID =  "SDXRow_SelectionTD_" + this.RootObject.Name + "_" + _ID ;
 this.Data = _Data
 this.Cells = new SDX_Cells(this.RootObject, this);
 this.Cells.Initialize() ;
 this.GetEvalObjectString = GetEvalObjectString ;
 this.Selected=false;
 this.SelectRow=SelectRow;
 this.ChangeSelectionStatus = ChangeSelectionStatus ;
 this.ChangeCellsClass = ChangeCellsClass ;
 this.CellClass=""
 this.Delete=Delete
 this.Hide=Hide
 this.Initialize = Initialize ;
 this.HTMLOutPut=HTMLOutPut
 function GetEvalObjectString()
 {
  return this.RootObject.Name + ".Rows.Rows[" + this.RootObject.GetRowMainArrayIndex(this.ID) + "]" ;
 }
 function ChangeCellsClass(_Class)
 {
  var columns = this.RootObject.Columns.GetVisibleColumns() ;
  for(var nX in columns)
  {
    var cell = this.Cells.GetCell(columns[nX].Key) ;
    if(_Class==null)
    {    
       this.RootObject.Styles.RemoveFonts(document.getElementById(cell.HTMLID).style)
    }
    else
    {
       this.RootObject.Styles.SetFont(document.getElementById(cell.HTMLID).style,this.RootObject.Styles.SelectedItemStyle)
    }
  }
 }
 function SelectRow()
 {
  if(this.RootObject.Rows.EditedCell!=null)
   this.RootObject.Rows.EditedCell.NormalMode()
  if(this.RootObject.Rows.SelectedCell!=null)
   this.RootObject.Rows.SelectedCell.NormalMode()
  this.RootObject.GroupByDrager.ClearGroupBy()
  if(SDXCtrlSelect==false)
   this.RootObject.Rows.ClearSelectedRows();
  
  for(var nX=this.RootObject.Rows.SelectedRows.length-1;nX>-1;nX--)
  {
   if(this.RootObject.Rows.SelectedRows[nX].ID == this.ID)
   {
       if(document.getElementById(this.RootObject.Rows.SelectedRows[nX].HTMLID))
       {
          this.RootObject.Rows.SelectedRows[nX].ChangeCellsClass(null) ;
          this.RootObject.Rows.SelectedRows[nX].ChangeSelectionStatus(0) ;
       }
       this.RootObject.Rows.SelectedRows.splice(nX,1);
       return;
   }
  }

  this.ChangeSelectionStatus(1)
  this.Selected=true;
  this.ChangeCellsClass("SelectedRow") ;
  this.RootObject.Rows.SelectedRows[this.RootObject.Rows.SelectedRows.length]=this;
  if(this.RootObject.AllowEditTemplate == true && SDXCtrlSelect==false)
   this.RootObject.Rows.ShowEditTemplate(this);
 }
 function ChangeSelectionStatus(_Status)
 {
  switch(_Status)
  {
   case 0: // EMPTY
   document.getElementById(this.SelectionTDHTMLID).innerHTML = ' '
   break ;
   case 1: // SELECT
   document.getElementById(this.SelectionTDHTMLID).innerHTML = '<img height=15 width=15 src=" + this.RootObject.ResourcePath + "images/RowSelectionSelect.gif>'
   break ;
   case 2: // NEW ROW
   document.getElementById(this.SelectionTDHTMLID).innerHTML = '*'
   break ;
   case 3: // EDIT ROW
   document.getElementById(this.SelectionTDHTMLID).innerHTML = '<img  height=15 width=15 src=" + this.RootObject.ResourcePath + "images/RowSelectionEdit.gif>'
   break ;
  }
 }
 function Delete()
 {
  this.RootObject.Rows.Rows[this.RootObject.GetRowMainArrayIndex(this.ID)].IsDeleted = true ;
  var deletedData = this.RootObject.Datas.InsertDeletedData(this.Data.KeyID) ;
  this.Hide();

  if(this.DataTable == null)
    return ;
  for(var nX in this.DataTable.Navigator.FilteredRows)
  {
   if(this.DataTable.Navigator.FilteredRows[nX].Data.KeyID == this.Data.KeyID)
   {
    this.DataTable.Navigator.FilteredRows.splice(nX,1);
   }
  }

  for(var nX in this.DataTable.Rows)
  {
   if(this.DataTable.Rows[nX].Data.KeyID == this.Data.KeyID)
   {
    this.DataTable.Rows.splice(nX,1);
   }
  }
 }
 function Hide()
 {
  document.getElementById(this.HTMLID).style.display='none';
 }
 function Initialize()
 {
 }
 function HTMLOutPut(_display)
 {
  var style = null ;
  if(this.RootObject.AlternateRowTurn == true)
  {
   this.RootObject.AlternateRowTurn = false ;
   style = this.RootObject.Styles.AlternatingItemStyle ;
  }
  else
  {
   this.RootObject.AlternateRowTurn = true ;
   style = this.RootObject.Styles.ItemStyle ;
  }
  var html = "<tr " + this.RootObject.Styles.GetStyleHTML(style) + " id=\"" + this.HTMLID + "\" " + (_display!=null?"style='display:" + _display + "'":"") + " object='" + this.GetEvalObjectString() + "'>"
  var groupBy = this.RootObject.Rows.Rows[this.RootObject.GetRowMainArrayIndex(this.ID)].DataTable.GroupBy;
  var groupByColSpan = (groupBy==null?0:groupBy.Level);
  html += "<td colspan='" + (groupByColSpan) + "' width=10 id=\"" + this.SelectionTDHTMLID + "\" onclick=\"" + this.RootObject.Name + ".Rows.Rows[" + this.ID + "].GetRowView().SelectRow()\" onmouseover=\"this.style.cursor='cursor'\"  " + this.RootObject.Styles.GetStyleHTML(this.RootObject.Styles.SelectorItemStyle) + " >&nbsp</td>";
  var columns = this.RootObject.Columns.GetVisibleColumns() ;
  for(var nX in columns)
  {
   var cell = this.Cells.GetCell(columns[nX].Key) ;
   html +=  "<td id=\"" + cell.HTMLID + "\"" +
            " onclick=\"" + cell.GetEvalObjectString() + ".OnClick()\"" +
            ">" +
            this.Cells.GetCell(columns[nX].Key).HTMLOutPut() +
            "</td>"
  }
  html += "</tr>";
  return html;
 }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions