Title: Help Me, Datagrid footer rows using database MySQL
Post by: jenggo_jojo on January 07, 2013, 12:04:11 AM
Help Me ... Give me Example footer rows using database MySQL ...
Title: Re: Help Me, Datagrid footer rows using database MySQL
Post by: peterg on February 15, 2013, 01:25:55 AM
hi, here my way. (notice i´m ab beginner in EasyUI ) php get data (post Insert, Update and Delete is in a other file.) <?php include '../include/funktion.php'; // mysql conn etc.
// table $dbtabelle = 'Menue';
$page = isset($_POST['page']) ? intval($_POST['page']) : 1; $rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10; $sort = isset($_POST['sort']) ? strval($_POST['sort']) : 'Position'; $order = isset($_POST['order']) ? strval($_POST['order']) : 'asc';
$offset = ($page-1)*$rows;
$result = array(); // Suche -------------
if(isset($_POST['Suche']) && !empty($_POST['Suche'])) { $Suche = mysql_real_escape_string($_POST['Suche']) ;
$where = " WHERE objekt_nr LIKE '%$Suche%' OR Position LIKE '%$Suche%' OR Text like '%$Suche%' OR href like '%$Suche%' OR onclick like '%$Suche%' OR icon like '%$Suche%' OR QEclass like '%$Suche%' OR data_options like '%$Suche%' OR Breite like '%$Suche%' OR target like '%$Suche%' "; } else { $where = '';}
// total ------------- $rs = mysql_query("SELECT COUNT(*) FROM $dbtabelle $where"); $row = mysql_fetch_row($rs); $result["total"] = $row[0];
// rows --------------- $rs = mysql_query("SELECT * FROM $dbtabelle $where ORDER BY $sort $order LIMIT $offset,$rows");
$items = array(); while($row = mysql_fetch_object($rs)) { array_push($items, $row); } $result["rows"] = $items;
// SUM() for footer -------------------- $rs = mysql_query("SELECT SUM(objekt_nr) AS objekt_nr, SUM(Position) AS Position FROM $dbtabelle $where");
while ($row = mysql_fetch_array($rs)) { $entry = array( 'objekt_nr' => 'Summe', 'Position' => euro($row['Position']), ); $jsonData[] = $entry; } $result["footer"] = $jsonData;
header("Content-type: application/json"); echo json_encode($result); ?> regards Peter
Title: Re: Help Me, Datagrid footer rows using database MySQL
Post by: Punkerr on February 15, 2013, 04:06:10 PM
Just check this post: http://www.jeasyui.com/forum/index.php?topic=1372.0
|