$objOverrideParameters in QDataGrid

Login or register to post comments
9 replies [Last post]
Offline
Joined: 07/07/2008

/**
* Similar to MetaAddColumn, except it creates a column for a Type-based Id.  You MUST specify
* the name of the Type class that this will attempt to use $NameArray against.
*
* Also, $mixContent cannot be an array.  Only a single field can be specified.
*
* @param mixed $mixContent string or QQNode from ItStatus
* @param string $strTypeClassName the name of the TypeClass to use $NameArray against
* @param mixed $objOverrideParameters
*/
public function MetaAddTypeColumn($mixContent, $strTypeClassName, $objOverrideParameters = null) {

Does anyone knows something about $objOverrideParameters object? How can I override and change the name of the header?

Offline
Joined: 03/31/2008

I think it works as name/value pairs, the same as the QDataGridColumn constructor.

RKotenko's picture
Offline
Joined: 07/03/2008

Correct. According to ControlBase documentation (where the function that processes this parameter is):

  /**
    * This allows you to set any properties, given by a name-value pair list
    * in mixOverrideArray.
    *
    * Each item in mixOverrideArray needs to be either a string in the format
    * of Property=Value or an array in the format of array(Property => Value).
    * OverrideAttributes() will basically call
    * $this->Property = Value for each string element in the array.
    *
    * Value can be surrounded by quotes... but this is optional.
    *
    * @param mixed[] $objOverrideArray the array of name-value pair items of  properties/attributes to override
   * @return void
  */

public final function OverrideAttributes($mixOverrideArray)

So, the obj prefix seems a misnomer as well.

On a related noted, as I backed traced from QListControl, I went through QListItem. The constructor takes the override arrray as a 5th parameter. Within the constructor, the presence of that parameter is not done by checking if it is empty or null (its default is null), but by using func_get_args, checking if the count is greater than 5, reversing the array, popping off the 1st four and the reversing the arrray again. Here:

$strOverrideArray = func_get_args();
if (count($strOverrideArray) > 4) {
  try {
    $strOverrideArray = array_reverse($strOverrideArray);
    array_pop($strOverrideArray);     
    array_pop($strOverrideArray);
    array_pop($strOverrideArray);
    array_pop($strOverrideArray);
    $strOverrideArray = array_reverse($strOverrideArray);
    $this->objItemStyle = new QListItemStyle();
    $this->objItemStyle->OverrideAttributes($strOverrideArray);

Could someone tell me a good reason for doing this instead of checking for the parameter? If there is no good reason, I wonder how many other places are coded in such a verbose manner....

Offline
Joined: 07/07/2008

Why not having something like:

$this->dtgItStatuses->MetaAddColumn(QQN::ItStatus()->ItStatusStatus, 'The Status');

In this simple way I could change the header text :-(

Offline
Joined: 07/07/2008

My solution:

/**
* A less crazy metacolumn
*
* @param mixed $mixContents
* @param string $objOverrideParameters[]
* @return QDataGridColumn
*/
public function MetaAddColumnWithHeader($mixContent, $strHeader) {
try {
$objNode = $this->ResolveContentItem($mixContent);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}

$objNewColumn = new QDataGridColumn(
$strHeader,
'<?=' . $objNode->GetDataGridHtml() . '?>',
array(
'OrderByClause' => QQ::OrderBy($objNode->GetDataGridOrderByNode()),
'ReverseOrderByClause' => QQ::OrderBy($objNode->GetDataGridOrderByNode(), false)
)
);

$this->AddColumn($objNewColumn);
return $objNewColumn;
}

I call the function in this way;

$this->dtgItStatuses->MetaAddColumnWithHeader(
   QQN::ItStatus()->ItStatusSystem, 'System'
);

Offline
Joined: 03/31/2008

I think it's already as easy as:

$this->dtgItStatuses->MetaAddColumn(QQN::ItStatus()->ItStatusStatus, 'Name=>The Status');

tony1kenobi's picture
Offline
Joined: 04/22/2009

just tried this out and it worked, note use of = and not =>

$this->dtgSwims->MetaAddColumn('Id','Name=Swim');

so in this case the heading of the id column for the swims grid (swimming database) becomes Swim instead of Id

Offline
Joined: 05/15/2009

In fact you can use array for the $objOverrideParameters, like this:

$this->dtgSwims->MetaAddColumn('Id', array('Name' => 'Swim', 'Html' => '<?= 'Id'.$_ITEM->Id ?>'));

Above code override Name (the header) and Html (for outputting the content).
We need this documented in Wiki :)

Offline
Joined: 10/15/2009

Hi,
i have a question about a simliar issue. I use MetaAddColumn, how to use the $objOverrideParameters for removing the sorting link, without having to modify the TagDataGridGen class ?

Offline
Joined: 10/30/2009

Hi. Thanks so much for this.
However, I have a question about outputting html in conjunction with the $_ITEM.
I have tested the following
$this->dtgSwims->MetaAddColumn('Id', array('Name' => 'Swim', 'Html' => '<?='div'.$_ITEM->Id.'/div' ?>'));
but instead of putting the content in a div, the special html characters are interpreted to display the 'blah'
Any idea as to how to put the output in a div inorder to style it with a customised class??

EDIT: Upon posting it looks like the my div tags are stripped out. Please imagine i have used html div tags where indicated