Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - celsol

Pages: [1]
1
it works... thanks a lot.

2
I forgot to say that from the console I can see that php returns a valid json

3
Help for ParamQuery Grid (free version) / The grid is not being filled
« on: January 21, 2017, 07:32:53 pm »
Hi! I'm new to pqgrid. I modified a demo script but it does not work.
Remote access via PHP.
The problem is that getData, on line 39, always return UNDEFINED...
Could someone help me, please?

The javascript:
<!DOCTYPE html>
<html>
<head>
<!--jQuery dependencies-->
   <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/themes/base/jquery-ui.css" />   
   <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
   <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>
<!--PQ Grid files-->
    <link rel="stylesheet" href="../grid-2.1.0/pqgrid.min.css" />
    <script src="../grid-2.1.0/pqgrid.min.js"></script>
<!--PQ Grid Office theme-->
    <link rel="stylesheet" href="../grid-2.1.0/themes/office/pqgrid.css" />
<script>
$(function () {
    var obj = {
        width: 700,
        height: 400,
        numberCell:{resizable:true,title:"#",width:30,minWidth:30},
//       editor: {type: 'textbox'},
        title: "ParamQuery Grid with JSON Data",
        resizable:true,
        scrollModel:{autoFit:true, theme:true},
        draggable:true
    };
    obj.colModel = [{
               title: "Procedimento",
               width: 150,
               dataIndx: "procedimento"
                }];
    obj.dataModel = { location: "remote",
                  dataType: "JSON",
                 method: "GET",
                 url: "get_procedimentos_cnes_1.php?cnes=2792176",
                      error: function(jq){
                         alert("jq error");               
                         console.log(JSON.stringify(jq));
                      },
                      getData: function (dataJSON) {
                          console.log(dataJSON.data);
                         return { data: dataJSON.data };
                    }};
   $("#grid_json").pqGrid(obj);
});
</script>   
</head>
<body>
<div id="grid_json" style="margin:100px;"></div>
</body>

</html>


The PHP:
<?php

session_start();
include "db_connect.php";
$cnes = $_GET['cnes'];
$sql = "SELECT DISTINCT
        b.vl_sh procedimento
    FROM
        aih_rd a,
        tb_procedimento b
    WHERE
            a.proc_rea = b.co_procedimento
            AND a.cnes = '$cnes'
";
//$_SESSION['sqlGrid'] = $sql;
$res = mysqli_query($con, $sql);
if (!$res) {
    echo "erro na consulta: " . mysqli_errno() . $sql;
}
$dbdata = array();
while ($row = $res->fetch_assoc()) {
    $dbdata[] = $row;
}
$res->close();
header('Content-Type: application/json');
//Print array in JSON format
echo json_encode($dbdata);

?>

Pages: [1]