HELP – SOS
I want to see the result of an arithmetic operation between two fields
in this case the sum of the field xx – zz sum field and the result is displayed under the name yy
“groupText” =>array(‘ Movil:{0} -Â Deuda: {summaryRound: 2, summaryRoundType = array(“xx” – “zz” =>array(“yy”=>”SUM”)}Â ‘),
all leave here full code
require_once ‘../../../jq-config.php’;
// include the jqGrid Class
require_once ABSPATH.”php/jqGrid.php”;
// include the driver class
require_once ABSPATH.”php/jqGridPdo.php”;
// Connection to the server
$conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD);
// Tell the db that we use utf-8
$conn->query(“SET NAMES utf8”);
// Create the jqGrid instance
$grid = new jqGridRender($conn);
// Write the SQL Query
$grid->SelectCommand = ‘SELECT n_orden, n_movil, fecha, concepto, debe, haber FROM cuentas_corrientes ‘;
// set the ouput format to json
$grid->dataType = ‘json’;
// Let the grid create the model from SQL query
$grid->setColModel();
// Set the url from where we obtain the data
$grid->setUrl(‘c_2.php’);
Â
$grid->setGridOptions(array(
   “rowNum”=>10,
   “sortname”=>”n_movil”,
   “rowList”=>array(50,100,150),
   “height”=>’auto’,
   “footerrow”=>true,
   “userDataOnFooter”=>true,
   “grouping”=>true,
   “groupingView”=>array(
    “groupField” => array(‘n_movil’, ‘n_orden’),
    “groupColumnShow” => array(true),
    “groupCollapse” => true,
    “shrinkToFit” => false, Â
    “groupText” =>array(‘ Movil:{0} - Deuda: {summaryRound: 2, summaryRoundType = array(“xx” –  “zz”=>array(“yy”=>”SUM”)} ‘),
     “groupDataSorted” => true,
    “groupSummary” => true,
    “groupSummaryPos” => true, Â
/*{ groupField: , groupColumnShow: [false], groupText: , groupCollapse: true, groupDataSorted: true, groupOrder: }*/
   )
   ));
 Â
// Change some property of the field(s)
$grid->setColProperty(“concepto”, array(“label”=>”Conceptos”, “width”=>250, “align”=>”left”, “background”=>”blue”));
$grid->setColProperty(“debe”, array(“label”=>”Debe”, “width”=>50, “align”=>”right” ));
$grid->setColProperty(“haber”, array(“label”=>”Haber”, “width”=>50, “align”=>”right”));
$grid->setColProperty(“n_movil”, array(“label”=>”Movil”, “width”=>20, “align”=>”center”));
$grid->setColProperty(“n_orden”, array(“label”=>”Orden”, “width”=>25, “align”=>”center”));
$grid->setColProperty(“fecha”, array(“label”=>”Fecha”, “width”=>45, “align”=>”center”,
   “formatter”=>”date”,
   “formatoptions”=>array(“srcformat”=>”Y-m-d H:i:s”,”newformat”=>”d/m/Y”)
 )
);
// Add a summary property to the debe Column
$grid->setColProperty(“haber”, array(“summaryType”=>”sum”, /*summaryTpl=>”Sum: {0}”,*/ “formatter”=>”number”));
$grid->setColProperty(“debe”, array(“summaryType”=>”sum”, /*summaryTpl=>”Sum: {0}”,*/ “formatter”=>”number”));
$summaryrows = array(“haber”=>array(“haber”=>”SUM”));
$summaryrows = array(“debe”=>array(“debe”=>”SUM”));
$summaryRoundType = array(“debe” – “haber” =>array(“saldo”=>”SUM”));
$grid->addUserData(array(“n_orden”=>”Total Gral:”));
Â
// Enjoy
$grid->renderGrid(‘#grid’,’#pager’,true, $summaryrows, null, true,true);
$conn = null;
?>
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top