fieldName) ? $paramList['key'] = $this->fieldName : $paramList['key'] = $this->columnName; $result = call_user_func($this->formatter, $paramList); return $result; } } class Ext_Structures_DataGrid extends Structures_DataGrid{ function bind($obj, $autofill=Null) { parent::bind($obj); if(!empty($autofill)) { $attribs = Null; if(is_array($autofill)) $attribs = $autofill; if(is_array($obj)) { if(count($obj)>0) { $row = current($obj); foreach($row as $k=>$v) { $this->addColumn(new Ext_Structures_DataGrid_Column(ucwords(str_replace('_', ' ', $k)), $k, $k, $attribs)); } } } elseif(is_a($obj, 'db_result')) { $cols = $obj->dbh->tableInfo($obj); foreach($cols as $k=>$v) { $k = $v['name']; $this->addColumn(new Ext_Structures_DataGrid_Column(ucwords(str_replace('_', ' ', $k)), $k, $k, $attribs)); } } } } /** *Following functions do what they say :). You must have defined column names to use *them however. I hesitate to use fieldNames since you might have diff. cols using same *field w/ diff formatters... */ function replaceColumn($column, $colname) { if(!is_a($column, 'structures_datagrid_column')) return false; $index = $this->findColumn($colname); if($index !== false) #identity op; index may be 0 { $this->columnSet[$index] = $column; } else $this->columnSet[] = $column; } function findColumn($colname) { foreach($this->columnSet as $k=>$v) { if($v->columnName == $colname) { return $k; } } return false; } function removeColumn($colname) { $index = $this->findColumn($colname); if($index !== false) #identity op; index may be 0 { unset($this->columnSet[$index]); } return $index; } }