Unable to display data in a grid
Hi,
I am trying the following:
<html>
<head>
<link rel="stylesheet" rel='nofollow' href="themes/bootstrap-theme/ej.web.all.min.css" />
<script src="scripts/external/jsrender.min.js"></script>
<script src="scripts/external/jquery-3.1.1.min.js"></script>
<script src="scripts/web/ej.web.all.min.js"> </script>
</head>
<body>
<?php require_once 'Src/AutoLoad.php'; ?>
<div class="cols-sample-area">
<?php
$Json = json_decode(file_get_contents("data.json"), true);
print_r($Json);
$col1 = new EJ\Grid\Column();
$col1->field("OrderID")->headerText("OrderID")->textAlign("right")->width(100);
$col2 = new EJ\Grid\Column();
$col2->field("CustomerID")->headerText("CustomerID")->width(70);
$col3 = new EJ\Grid\Column();
$col3->field("EmployeeID")->headerText("EmployeeID")->textAlign("right")->width(70);
$col4 = new EJ\Grid\Column();
$col4->field("ShipCountry")->headerText("ShipCountry")->width(70);
$col5 = new EJ\Grid\Column();
$col5->field("Freight")->headerText("Freight")->textAlign("right")->format("{0:C}")->width(70);
$gridColumns = array($col1,$col2,$col3,$col4,$col5);
$grid = new EJ\Grid("Grid");
$column=new EJ\Grid\Column();
echo $grid -> dataSource($Json)->allowPaging(true)->columns($gridColumns)->render();
?>
</div>
<style>
.cols-sample-area {
margin: 0 auto;
float: none;
}
</style>
</body>
</html>
The data.json is from syncfusion samples.
The program does show that it is reading the data.json correctly bu displaying its contents in text form.
However, when it comes to displaying in the grid, it says "33 lines", but it is always empty and not displaying any data in the grid.
I have tried this with and without the line
<script src="scripts/external/jsrender.min.js"></script>
in the header.
What is the right way to do this?
TIA
Mohan.
SIGN IN To post a reply.
4 Replies
MO
Mohan
September 19, 2017 04:46 PM UTC
Replying my own question - may be this would help someone else..
The order in which js files are listed in the header makes a difference (On hindsight this is obvious!)
T changed the header like so:
<head>
<link rel="stylesheet" rel='nofollow' href="themes/bootstrap-theme/ej.web.all.min.css" />
<script src="scripts/external/jquery-3.1.1.min.js"></script>
<script src="scripts/external/jsrender.min.js"></script>
<script src="scripts/web/ej.web.all.min.js"> </script>
</head>
and it worked.
Mohan.
MS
Mani Sankar Durai
Syncfusion Team
September 20, 2017 11:23 AM UTC
Hi Mohan,
We are happy to hear that your problem has been solved.
Please let us know if you need further assistance.
Regards,
Manisankar Durai.
RA
raunakgarg
June 12, 2018 10:06 AM UTC
Thanks Mohan for giving solution of the above problem. This problem could occur with any fresher or even experienced in PHP.
KM
Kuralarasan Muthusamy
Syncfusion Team
June 13, 2018 06:24 AM UTC
Hi Customer,
Thank you all.
Regards,
Kuralarasan M.
SIGN IN To post a reply.
- 4 Replies
- 4 Participants
-
MO Mohan
- Sep 19, 2017 03:59 PM UTC
- Jun 13, 2018 06:24 AM UTC