
subclass(RecordListViewGrid, RecordListView);
function RecordListViewGrid(id)
{
  RecordListView.call(this, id);
}

RecordListViewGrid.prototype.init = function(parent)
{
  RecordListView.prototype.init.call(this, parent);

  this.refreshItems = true;

  this.parent.onRecordModify.addEventListener(new REventListener(this.onRecordModifyListener, this));
  this.parent.onReLayout.addEventListener(new REventListener(this.onReLayoutListener, this));
  this.onShow.addEventListener(new REventListener(this.onShowListener, this));
}

RecordListViewGrid.prototype.attach = function(node)
{
  this.dataGridPanel.attach(node);
}

RecordListViewGrid.prototype.onReLayoutListener = function()
{
  this.dataGridPanel.resize();
}

RecordListViewGrid.prototype.onRecordModifyListener = function()
{
  if (this.parent.getCurrentView() == this)
    this.requestItems();
  else
    this.refreshItems = true;
}

RecordListViewGrid.prototype.onShowListener = function()
{
  if (this.refreshItems)
  {
    this.requestItems();
    this.refreshItems = false;
  }
  else
  {
    this.onDataChange.trigger(this.totalRows, this.getStartIndex());
  }
}
