本文整理汇总了PHP中TTable::add方法的典型用法代码示例。如果您正苦于以下问题:PHP TTable::add方法的具体用法?PHP TTable::add怎么用?PHP TTable::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TTable
的用法示例。
在下文中一共展示了TTable::add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
/**
* Show the widget at the screen
*/
public function show()
{
// include the needed libraries and styles
if ($this->fields) {
$table = new TTable();
$mdr = array();
// mandatory
$fields = array();
$i = 0;
foreach ($this->fields as $name => $obj) {
$row = $table->addRow();
$label = new TLabel($obj->text);
if ($obj->inform) {
$row->addCell($label);
$row->addCell($obj->field);
}
$fields[] = $name;
$post_fields[$name] = 1;
$obj->field->setName($this->name . '_' . $name);
if (get_class($obj->field) == 'TComboCombined') {
$fields[] = $obj->field->getTextName();
$obj->field->setTextName($this->name . '_' . $obj->field->getTextName());
$i++;
}
$i++;
}
$table->show();
}
// check whether the widget is non-editable
if (parent::getEditable()) {
// create three buttons to control the MultiField
$add = new TButton("{$this->name}btnStore");
$add->setLabel(TAdiantiCoreTranslator::translate('Register'));
//$add->setName("{$this->name}btnStore");
$add->setImage('ico_save.png');
$add->addFunction("mtf{$this->name}.addRowFromFormFields()");
$del = new TButton("{$this->name}btnDelete");
$del->setLabel(TAdiantiCoreTranslator::translate('Delete'));
$del->setImage('ico_delete.png');
$can = new TButton("{$this->name}btnCancel");
$can->setLabel(TAdiantiCoreTranslator::translate('Cancel'));
$can->setImage('ico_close.png');
$table = new TTable();
$row = $table->addRow();
$row->addCell($add);
$row->addCell($del);
$row->addCell($can);
$table->show();
}
// create the MultiField Panel
$panel = new TElement('div');
$panel->{'class'} = "multifieldDiv";
$input = new THidden($this->name);
$panel->add($input);
// create the MultiField DataGrid Header
$table = new TTable();
$table->id = "{$this->name}mfTable";
$head = new TElement('thead');
$table->add($head);
$row = new TTableRow();
$head->add($row);
// fill the MultiField DataGrid
foreach ($this->fields as $obj) {
$c = $obj->text;
if (get_class($obj->field) == 'TComboCombined') {
$row->addCell('ID');
}
$cell = $row->addCell($c);
$cell->width = $obj->size . 'px';
}
$body = new TElement('tbody');
$table->add($body);
if ($this->objects) {
foreach ($this->objects as $obj) {
if (isset($obj->id)) {
$row = new TTableRow();
$row->dbId = $obj->id;
$body->add($row);
} else {
$row = new TTableRow();
$body->add($row);
}
foreach ($fields as $name) {
$cell = $row->addCell(is_null($obj->{$name}) ? '' : $obj->{$name});
if (isset($this->fields[$name]->size)) {
$cell->style = 'width:' . $this->fields[$name]->size . 'px';
}
}
}
}
$panel->add($table);
$panel->show();
echo '<script type="text/javascript">';
echo "var mtf{$this->name};";
//echo '$(document).ready(function() {';
echo "mtf{$this->name} = new MultiField('{$this->name}mfTable',{$this->width},{$this->height});\n";
$s = implode("','", $fields);
//.........这里部分代码省略.........
示例2: createModel
/**
* Creates the DataGrid Structure
*/
public function createModel()
{
if (!$this->columns) {
return;
}
$thead = new TElement('thead');
$thead->{'class'} = 'tdatagrid_head';
parent::add($thead);
$row = new TElement('tr');
if ($this->scrollable) {
$row->{'style'} = 'display:block';
}
$thead->add($row);
// add some cells for the actions
if ($this->actions) {
foreach ($this->actions as $action) {
$cell = new TElement('td');
$row->add($cell);
$cell->add(' ');
$cell->{'class'} = 'tdatagrid_action';
$cell->width = '16px';
}
// the last one has right border
$cell->{'class'} = 'tdatagrid_col';
}
// add some cells for the data
if ($this->columns) {
// iterate the DataGrid columns
foreach ($this->columns as $column) {
// get the column properties
$name = $column->getName();
$label = ' ' . $column->getLabel() . ' ';
$align = $column->getAlign();
$width = $column->getWidth();
if (isset($_GET['order'])) {
if ($_GET['order'] == $name) {
$label .= '<img src="lib/adianti/images/ico_down.png">';
}
}
// add a cell with the columns label
$cell = new TElement('td');
$row->add($cell);
$cell->add($label);
$cell->{'class'} = 'tdatagrid_col';
$cell->align = $align;
if ($width) {
//$cell-> width = $width.'px';
$cell->width = $width + 8 . 'px';
}
// verify if the column has an attached action
if ($column->getAction()) {
$url = $column->getAction();
$cell->onmouseover = "this.className='tdatagrid_col_over';";
$cell->onmouseout = "this.className='tdatagrid_col'";
$cell->href = $url;
$cell->generator = 'adianti';
}
}
if ($this->scrollable) {
$cell = new TElement('td');
$cell->{'class'} = 'tdatagrid_col';
$row->add($cell);
$cell->add(' ');
$cell->width = '12px';
}
}
// add one row to the DataGrid
$this->tbody = new TElement('tbody');
$this->tbody->{'class'} = 'tdatagrid_body';
if ($this->scrollable) {
$this->tbody->{'style'} = "height: {$this->height}px; display: block; overflow-y:scroll; overflow-x:hidden;";
}
parent::add($this->tbody);
$this->modelCreated = TRUE;
}