question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JSGrid is not displaying Data in grid (PHP)

See original GitHub issue

@tabalinas 1.This is my js code: in page (udc-group.php )

`><script> $( document ).ready(function() {

   var db={
    loadData: function (filter) {
            var data = $.Deferred();
             $.ajax({
                type: "GET",
                contentType: "application/json",
                url: "udc/index.php",
                dataType: "json",
                data:filter
            }).done(function (response) {
                
                data.resolve(response.d);
            });
            return data.promise();
        }
   } 

$("#jsGrid").jsGrid({
    width: "100%",
    height: "50%",
    filtering: true,
    inserting: true,
    editing: true,
    sorting: true,
    paging: true,
    autoload: true,
    pageSize: 10,
    pageLoading:true,

    
    controller:db,
    
          
          

    fields: [
        { name: "ID", type: "number", width: 50},
        { name: "DTSY", type: "number", width: 50 },
        { name: "DTRT", type: "text", width: 50 },
        { name: "DTDL01", type:"text", width: 200  },
        { name: "DTUSEQ", type:"number", width: 200  },
        { name: "DTUCD1", type:"text", width: 200  },
        { name: "DTCDL", type:"text", width: 200  },
        { type: "control" }
    ]
});

});

</script>`

`<!--------------------->`
`<!----` 1. PHP SCRIPT in page(iniudc.php)-->
`<!------------------------------------------------>`
`<?php

class iniudc {
    public $ID;
    public $DTSY;
    public $DTRT;
    public $DTDL01;
    public $DTUSEQ;
    public $DTUCD1;
    public $DTCDL;
    
}

?>`
``<!------------------------------------------------>``
``<!----` 2. PHP SCRIPT in page(udc.php)------>`
`<!------------------------------------------------>`
<?php

include "iniudc.php";

class udc {

    protected $db;

    public function __construct(PDO $db) {
        $this->db = $db;
    }

    private function read($row) {
        $result = new iniudc();
        $result->ID = $row["ID"];
        $result->DTSY = $row["DTSY"];
        $result->DTRT = $row["DTRT"];
        $result->DTDL01 = $row["DTDL01"];
        $result->DTUSEQ = $row["DTUSEQ"] ;
        $result->DTUCD1 = $row["DTUCD1"] ;
        $result->DTCDL = $row["DTCDL"] ;
        
        return $result;
    }

    
    public function getAll($filter) {
        $ID = "%" . $filter["ID"] . "%";
        $DTSY = "%" . $filter["DTSY"] . "%";
        $DTRT ="%". $filter["DTRT"] . "%";
        $DTDL01 ="%". $filter["DTDL01"] . "%";
        $DTUSEQ ="%". $filter["DTUSEQ"] . "%";
        $DTUCD1 ="%". $filter["DTUCD1"] . "%";
        $DTCDL ="%". $filter["DTCDL"] . "%";

        $sql = "SELECT * FROM f0004a WHERE ID LIKE :ID AND DTSY LIKE :DTSY AND DTRT LIKE :DTRT AND DTDL01 LIKE :DTDL01 AND DTUSEQ LIKE :DTUSEQ AND DTUCD1 LIKE :DTUCD1 AND DTCDL LIKE :DTCDL";
        $q = $this->db->prepare($sql);
        
        $q->bindParam(":ID", $ID);
        $q->bindParam(":DTSY", $DTSY);
        $q->bindParam(":DTRT", $DTRT);
        $q->bindParam(":DTDL01", $DTDL01);
        $q->bindParam(":DTUSEQ", $DTUSEQ);
        $q->bindParam(":DTUCD1", $DTUCD1);
        $q->bindParam(":DTCDL", $DTCDL);
        $q->execute();
        $rows = $q->fetchAll();

        $result = array();
        foreach($rows as $row) {
            array_push($result, $this->read($row));
        }
        return $result;
    }
    

}

?>
<!------------------------------------------------>
<!---- 3. PHP SCRIPT in page(index.php) which is in folder 'udc' like PATH this /udc/index.php------>
<!------------------------------------------------>
<?php

include "../models/udc.php";

$config = include("../db/config.php");
$db = new PDO($config["db"], $config["username"], $config["password"]);
$countries = new udc($db);


switch($_SERVER["REQUEST_METHOD"]) {
    case "GET":
        $result = $countries->getAll(array(
        	"ID" => $_GET["ID"],
            "DTSY" => $_GET["DTSY"],
            "DTRT" => $_GET["DTRT"],
            "DTDL01" => $_GET["DTDL01"],
            "DTUSEQ" => $_GET["DTUSEQ"],
            "DTUCD1" => $_GET["DTUCD1"],
            "DTCDL" => $_GET["DTCDL"]
         ));
        break;
}


header("Content-Type: application/json");
echo json_encode($result);

?>
<!------------------------------------------------>
<!---- Sir please help to solve this issue .....the problem is - when my main page 'udc-group.php' 
loading the JSGrid display "Not Found" -->
<!------------------------------------------------>

jsgrid

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:9

github_iconTop GitHub Comments

2reactions
heiovskycommented, Aug 27, 2018

#1056 #1001 #908

3 issues that i have answered something about ajax loading. You can easily find another 20. Start with reading documetation. There is nothing easier than jsGrid.

2reactions
preichowcommented, Aug 27, 2018

I gave up on jsgrid, after trying to four days of trying to get a grid reading from mysql. The simple static grids work, but none of the ajax example work locally.

It’s a sad sign when the examples on their website don’t even work correctly, like the OD Service that just spins forever because a permissions issue.

It’s also a sad sign when the examples on GitHub don’t even work. In fact, I can’t even find a working example on the internet. Why is it so damn difficult to configure this thing?

This software is frustrating…way too difficult to use…I’m moving on.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JS Grid not showing data in table - Stack Overflow
I have a php file with my JS Grid table which is also visible: My code for the table: $(document).ready(function() { $('#contacts_table').
Read more >
NO data display in the grid - JavaScript - EJ 2 - Syncfusion
The reported problem is occurring because the data is not returned to the Grid in the proper format. For the ODataV4 adaptor, ...
Read more >
Problem loading grid from PHP data source - Telerik
I'm trying the Kendo grid for the first time and am having a problem loading the data from a query done in PHP....
Read more >
jsGrid: Lightweight Grid jQuery Plugin
jsGrid is a lightweight client-side data grid control based on jQuery. It supports basic grid operations like inserting, filtering, editing, deleting, ...
Read more >
grid data not loading – Grid 4 PHP – Support Center - PHP Grid
It is possible to know grid-visible state by .jqGrid('getGridParam'…) or similar? 0 Vote Up Vote Down.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found