本文整理汇总了PHP中DataGrid::SetHeaderAttribs方法的典型用法代码示例。如果您正苦于以下问题:PHP DataGrid::SetHeaderAttribs方法的具体用法?PHP DataGrid::SetHeaderAttribs怎么用?PHP DataGrid::SetHeaderAttribs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataGrid
的用法示例。
在下文中一共展示了DataGrid::SetHeaderAttribs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: BuildTable
function BuildTable($db, $tbl, $pos = 1, $sortcol = '', $sortdesc = 0)
{
$pospage = 8;
//the display properties for the odd and even rows
$odd = array('style' => 'background-color: #CCCCCC;');
$even = array('style' => 'background-color: #EEEEEE;');
//the display properties for the overall table
$table = array('cellpadding' => '3', 'cellspacing' => '0');
//table column header formatting properties
$headerattrib = array('style' => 'background-color: skyblue; cursor:pointer;');
//get data and rowcount
$possql = $pos - 1;
if ($sortcol) {
$orderby = " ORDER BY {$sortcol} " . ($sortdesc ? 'DESC' : '');
}
$result = mysql_query("SELECT SQL_CALC_FOUND_ROWS * FROM {$tbl} {$orderby} LIMIT {$possql},{$pospage}");
$poscnt = mysql_result(mysql_query("SELECT FOUND_ROWS()"), 0, 0);
while ($row = mysql_fetch_assoc($result)) {
$data[] = $row;
}
//build the datagrid
require_once "./AjaxDataGrid.class.php";
$at = new DataGrid($data, $_SERVER['PHP_SELF'] . "?db={$db}");
$at->JsClass = $tbl;
$at->pos = $pos;
$at->pospage = $pospage;
$at->poscnt = $poscnt;
$at->SetEvenRowAttribs($even);
$at->SetOddRowAttribs($odd);
$at->SetTableAttribs($table);
$at->SetHeaderAttribs($headerattrib);
//NOTE: the columns types are setup automatically - first column readonly,
//rest text. See example.php for setting up columns manually.
return $at;
}
示例2: BuildTable
function BuildTable($cls, $pos = 1, $sortcol = '', $sortdesc = 0)
{
$pospage = 8;
global $data_file;
//the display properties for the odd and even rows
$odd = array('style' => 'background-color: #CCCCCC;');
$even = array('style' => 'background-color: #EEEEEE;');
//the display properties for the overall table
$table = array('cellpadding' => '3', 'cellspacing' => '0');
//table column header formatting properties
$headerattrib = array('style' => 'background-color: skyblue; cursor:pointer;');
$data = file_get_contents($data_file);
$data = unserialize($data);
//sort
if ($sortcol) {
// Obtain a list of columns
foreach ($data as $key => $row) {
$sort1[$key] = $row[$sortcol];
$data[$key]['key'] = $key;
}
// Sort the data
if ($sortdesc) {
array_multisort($sort1, SORT_DESC, $data);
} else {
array_multisort($sort1, SORT_ASC, $data);
}
}
//filter rows
$pos--;
//zero based position
if ($pos < 0) {
$pos = 0;
}
$poscnt = count($data);
if ($pos >= $poscnt) {
$pos = floor(($poscnt - 1) / $pospage) * $pospage;
}
$r = 0;
foreach ($data as $k => $v) {
if ($r < $pos || $r >= $pos + $pospage) {
unset($data[$k]);
}
$r++;
}
require_once "./AjaxDataGrid.class.php";
$at = new DataGrid($data, "");
$at->JsClass = $cls;
$at->pos = $pos + 1;
//one based position
$at->pospage = $pospage;
$at->poscnt = $poscnt;
$at->SetEvenRowAttribs($even);
$at->SetOddRowAttribs($odd);
$at->SetTableAttribs($table);
$at->SetHeaderAttribs($headerattrib);
$at->AddColumnReadonly("id", "id[Readonly]");
$at->AddColumnHidden("col1", "col1[Hidden]");
$at->AddColumnText("col2", "col2[Text]");
$at->AddColumnSelect("col3", "col3[Select]", array("1st option", "2nd option", "test ' qoute", "test \" dqoute", "test < lt", "test & amp"));
$at->AddColumnSelectkey("col4", "col4[Selectkey]", array("key1" => "1st option", "key2" => "2nd option", "key3" => "test ' qoute", "key4" => "test \" dqoute", "key5" => "test < lt", "key6" => "test & amp"));
$at->AddColumnCheckbox("col5", "col5[Checkbox]");
$at->AddColumnTextarea("col6", "col6[Textarea]", 200, 100);
return $at;
}