Exemple #1
0
function activewidgets_grid($name, &$data)
{
    $row_count = @mysql_num_rows($data);
    $column_count = @mysql_num_fields($data);
    $columns = "var " . $name . "_columns = [\n";
    for ($i = 0; $i < $column_count; $i++) {
        $columns .= "\"" . @mysql_field_name($data, $i) . "\", ";
    }
    $columns .= "\n];\n";
    $rows = "var " . $name . "_data = [\n";
    while ($result = @mysql_fetch_array($data)) {
        $rows .= "[";
        for ($i = 0; $i < $column_count; $i++) {
            $rows .= "\"" . activewidgets_html($result[$i]) . "\", ";
        }
        $rows .= "],\n";
    }
    $rows .= "];\n";
    $html = "<" . "script" . ">\n";
    $html .= $columns;
    $html .= $rows;
    $html .= "try {\n";
    $html .= "  var {$name} = new Active.Controls.Grid;\n";
    $html .= "  {$name}.setRowCount({$row_count});\n";
    $html .= "  {$name}.setColumnCount({$column_count});\n";
    $html .= "  {$name}.setDataText(function(i, j){return " . $name . "_data[i][j]});\n";
    $html .= "  {$name}.setColumnText(function(i){return " . $name . "_columns[i]});\n";
    $html .= "  document.write({$name});\n";
    $html .= "}\n";
    $html .= "catch (error){\n";
    $html .= "  document.write(error.description);\n";
    $html .= "}\n";
    $html .= "</" . "script" . ">\n";
    return $html;
}
Exemple #2
0
function listuser_grid($name, $column_name, $data, $filename, $sid)
{
    $row_count = count($data);
    $column_count = count($column_name);
    $columns = "var " . $name . "_columns = [\n";
    foreach ($column_name as $value) {
        $columns .= "\"" . $value . "\", ";
    }
    $columns .= "\n];\n";
    $rows = "var " . $name . "_data = [\n";
    for ($k = 0; $k < $row_count; $k++) {
        for ($j = 0; $j < $column_count; $j++) {
            if ($j == 0) {
                $data[$k][$j] = "<a style='cursor:hand font-size: 10px; text-decoration: none; color: #800000' href='Modules.php?modname=" . $filename . "&" . $sid . "=" . $data[$k][$j + 2] . "'><b>" . $data[$k][$j] . "</b></a>";
            }
        }
    }
    for ($k = 0; $k < $row_count; $k++) {
        $rows .= "[";
        for ($j = 0; $j < $column_count; $j++) {
            if ($j == 0) {
                $rows .= "\"" . $data[$k][$j] . "\", ";
            } else {
                $rows .= "\"" . activewidgets_html($data[$k][$j]) . "\", ";
            }
        }
        $rows .= "],\n";
    }
    $rows .= "];\n";
    $html = "<style>\r\n\t\t.active-controls-grid {height: 100%; font: menu;}\r\n\t\t//.active-grid-row{background: #ffffff;}\r\n\t\t\r\n\t\t//.active-column-0 {width: 400px; background-color: #E3F1F9;}\r\n\t\t.active-column-0 {width: 400px; }\r\n\t\t.active-column-3 {width: 188px;}\r\n\t\t\r\n\t\t.active-grid-column {border-right: 1px solid threedlightshadow;}\r\n\t\t.active-grid-row {border-bottom: 1px solid threedlightshadow;}\r\n\t\t\r\n\r\n\t\t//row heighlighting\r\n\t\t.active-row-highlight {background-color: #f6f6ef}\r\n    \t.active-row-highlight .active-row-cell {background-color: #f6f6ef}\r\n\r\n\t\t\r\n\t\t//column header background\r\n\t\t.active-scroll-left .active-box-item {\r\n        background: green;\r\n    \t}\r\n\r\n    \t/* column header background */\r\n    \t.active-scroll-top .active-box-item {\r\n        background-image:url('images/column_header.jpg');\r\n        font-weight: bold;\r\n\r\n            }\r\n\r\n\t\t.active-scroll-left, .active-scroll-corner {display: none} \r\n    \t.active-scroll-top, .active-scroll-data {padding-left: 0px}\r\n    \t\r\n    \t\r\n    \t.active-scroll-data .active-column-3 {\r\n        border-right: 0px double #cccccc;\r\n\t    }\r\n\t\t\r\n\t\t.active-scroll-top .active-column-3 {\r\n\t    border-right: 0px double #cccccc;\r\n\t\t}\r\n\r\n\r\n\r\n\r\n\t\t\r\n\r\n\r\n\r\n\r\n\t</style>\r\n";
    $html .= "<" . "script" . ">\n";
    $html .= $columns;
    $html .= $rows;
    $html .= "try {\n";
    $html .= "  var {$name} = new Active.Controls.Grid;\n";
    //For Paging
    $html .= "  \n " . $name . ".setModel(\"row\", new Active.Rows.Page); \n";
    $html .= "  {$name}.setProperty(\"row/count\",{$row_count});\n";
    $html .= "  {$name}.setProperty(\"column/count\",{$column_count});\n";
    $html .= "  {$name}.setProperty(\"data/text\",function(i, j){return " . $name . "_data[i][j]});\n";
    $html .= "  {$name}.setColumnText(function(i){return " . $name . "_columns[i]});\n";
    //For Alternate row
    $html .= " \t\n var alternate = function(){";
    $html .= "  \n return this.getRowProperty('order') % 2 ? '#efefef' : '#ffffff';";
    $html .= "  \n }";
    $html .= "  \n var row = new Active.Templates.Row;";
    $html .= "  \n row.setStyle('background', alternate);";
    $html .= "  \n obj.setTemplate('row', row);";
    //For Row hilighting
    $html .= "  \n row.setEvent('onmouseover', \"mouseover(this, 'active-row-highlight')\");";
    $html .= "  \n row.setEvent('onmouseout', \"mouseout(this, 'active-row-highlight')\");";
    $html .= "  \n obj.setTemplate('row', row);";
    //For Column-Header Height
    $html .= "  \n obj.setColumnHeaderHeight(24);";
    //For Paging
    $html .= "  \n obj.setProperty(\"row/pageSize\", 50);";
    $html .= "  document.write({$name});\n";
    $html .= "}\n";
    $html .= "catch (error){\n";
    $html .= "  document.write(error.description);\n";
    $html .= "}\n";
    $html .= "</" . "script" . ">\n";
    $html .= "\t<script>\r\n\tfunction goToPage(delta){\r\n\t\tvar count = obj.getProperty(\"row/pageCount\");\r\n\t\tvar number = obj.getProperty(\"row/pageNumber\");\r\n\t\tnumber += delta;\r\n\t\tif (number < 0) {number = 0}\r\n\t\tif (number > count-1) {number = count-1}\r\n\t\tdocument.getElementById('pageLabel').innerHTML = \"Page \" + (number + 1) + \" of \" + count + \" (Total No of Records: " . $row_count . ") \";\r\n\r\n\t\tobj.setProperty(\"row/pageNumber\", number);\r\n\t\tobj.refresh();\r\n\t}\r\n\r\n\tgoToPage(0);\r\n\t</script>";
    return $html;
}