Home > Articles

  • Print
  • + Share This
Like this article? We recommend

Redoing the Object Model

I've resisted the temptation to expand in the area of properties for one basic reason. Rows, columns, and cells can already be highlighted or selected for edit. We need multiple flags for which combinations are allowable. If I were to just hang behaviors off the existing tree, more bugs would follow.

As a consequence, the following object members will be created:

function DGSeries(itemNum, cssStyle)
{
  this.itemNum = itemNum;
  this.cssStyle = cssStyle;
}

function DGCell(rowNum, colNum, htmlData, cssStyle)
{
  this.colNum = colNum;
  this.rowNum = rowNum;
  this.dataType = "string"

  this.htmlData = htmlData;
  this.cssStyle = cssStyle;
}

While I could have chosen to break these into rows and columns, I generally haven't found any compelling reason for them to have different sets of properties. The selection events are based on the DataGrid itself. This division is really for the purposes of data formatting and more granular handling of items. And now, a style string can be applied to each element of the table as it's drawn.

This is all well and good, but now our method of adding data seems quite a bit more clunky than before. It's not even that the internal storage format of arrays of arrays is so bad, but the wholesale handoff of large batches only applies if the data is fairly uniform, which doesn't begin to tap the new potential power and flexibility. To go any further, we should probably start to manage these in the more traditional grid fashion—by rows, columns, and cells.

  • + Share This
  • 🔖 Save To Your Account