https://drive.google.com/file/d/0B9u-aHmiNCiBY3hjZkZzaTk4LVk/view
$col = array();
$col["title"] = "Khách Hàng";
$col["name"] = "khachhang";
$col["dbname"] = "wip_workreport.khachhang";
$col["width"] = "20";
$col["align"] = "center";
$col["search"] = true;
$col["editable"] = true;
$col["edittype"] = "select";
$str = $g->get_dropdown_values("select idkh as k, tenkhachhang as v from wip_khachhang");
$col["editoptions"] = array(
"value"=>$str,
"onchange" => array( "sql"=>"select idnh as k, tennhanhang as v from wip_nhanhang WHERE idkhachhang = '{khachhang}'",
"update_field" => "nhanhang" )
);
$col["formatter"] = "select"; // display label, not value
$col["stype"] = "select"; // enable dropdown search
$col["searchoptions"] = array("value" => ":;".$str);
$col["editrules"] = array("number"=>true,"minValue"=>1,"required"=>true);
$cols[] = $col;
$col = array();
$col["title"] = "Nhãn Hàng";
$col["name"] = "nhanhang";
$col["dbname"] = "wip_workreport.nhanhang";
$col["width"] = "20";
$col["align"] = "center";
$col["search"] = true;
$col["editable"] = true;
$col["edittype"] = "select";
$str = $g->get_dropdown_values("select idnh as k, tennhanhang as v from wip_nhanhang");
$col["editoptions"] = array(
"value"=>$str
);
$col["formatter"] = "select"; // display label, not value
$col["stype"] = "select"; // enable dropdown search
$col["searchoptions"] = array("value" => ":;".$str);
$col["editrules"] = array("number"=>true,"minValue"=>1,"required"=>true);
$cols[] = $col;
—————
and Not sum
$col = array();
$col["title"] = "Giá Trị Năm Trước"; // caption of column
$col["name"] = "giatrinamtruoc";
$col["width"] = "25";
$col["formatter"] = "number";
$col["editable"] = true;
$col["editrules"] = array("number"=>true);
$col["formatoptions"] = array("thousandsSeparator" => ",",
"decimalSeparator" => ".",
"decimalPlaces" => 0);
$col["summaryType"] = "sum"; // available grouping fx: sum, count, min, max, avg
$col["summaryTpl"] = '<b>Tổng:{0}đ</b>'; // display html for summary row – work when "groupSummary" is set true. search below
$cols[] = $col;
$col = array();
$col["title"] = "Giá Trị Năm Nay"; // caption of column
$col["name"] = "giatrinamnay";
$col["width"] = "25";
$col["editable"] = true;
$col["editrules"] = array("number"=>true);
$col["formatoptions"] = array("thousandsSeparator" => ",",
"decimalSeparator" => ".",
"decimalPlaces" => 0);
$col["summaryType"] = "sum"; // available grouping fx: sum, count, min, max, avg
$col["summaryTpl"] = '<b>Tổng:{0}đ</b>'; // display html for summary row – work when "groupSummary" is set true. search below
$cols[] = $col;
———————————————
$g->set_columns($cols);
$e["on_data_display"] = array("giatrinamtruoc", null, true);
$e["on_data_display"] = array("giatrinamnay", null, true);
$g->set_events($e);
function giatrinamtruoc($data)
{
$total = 0;
foreach($data["params"] as $d)
{
$total += $d["giatrinamtruoc"];
}
$data["params"]["userdata"] = array("ketthuc"=>"Tổng: ","giatrinamtruoc"=>$total." VNĐ");
}
function giatrinamnay($data)
{
$total = 0;
foreach($data["params"] as $d)
{
$total += $d["giatrinamnay"];
}
$data["params"]["userdata"] = array("ketthuc"=>"Tổng: ","giatrinamnay"=>$total." VNĐ");
}