jQWidgets Forums
jQuery UI Widgets › Forums › Grid › I am getting no results
Tagged: datagrid
This topic contains 9 replies, has 2 voices, and was last updated by kbloem 11 years, 1 month ago.
-
AuthorI am getting no results Posts
-
I just started with jquery so forgive me if this is a stupid question…
There are two files, takenlijstdata.php, wich gives me an array with values and takenlijst.php wich i display below.
`<!DOCTYPE html>
<html lang=”en”>
<head>
<title id=’Description’>Testpagina.</title>
<script type=”text/javascript” src=”http://www.site.com/jquery/scripts/jquery-1.10.2.js”></script>
<script type=”text/javascript” src=”http://www.site.com/jquery/jqwidgets/jqxcore.js”></script>
<script type=”text/javascript” src=”http://www.site.com/jquery/jqwidgets/jqxdata.js”></script>
<script type=”text/javascript” src=”http://www.site.com/jquery/jqwidgets/jqxbuttons.js”></script>
<script type=”text/javascript” src=”http://www.site.com/jquery/jqwidgets/jqxscrollbar.js”></script>
<script type=”text/javascript” src=”http://www.site.com/jquery/jqwidgets/jqxlistbox.js”></script>
<script type=”text/javascript” src=”http://www.site.com/jquery/jqwidgets/jqxdropdownlist.js”></script>
<script type=”text/javascript” src=”http://www.site.com/jquery/jqwidgets/jqxmenu.js”></script>
<script type=”text/javascript” src=”http://www.site.com/jquery/jqwidgets/jqxgrid.js”></script>
<script type=”text/javascript” src=”http://www.site.com/jquery/jqwidgets/jqxgrid.filter.js”></script>
<script type=”text/javascript” src=”http://www.site.com/jquery/jqwidgets/jqxgrid.sort.js”></script>
<script type=”text/javascript” src=”http://www.site.com/jquery/jqwidgets/jqxgrid.selection.js”></script>
<script type=”text/javascript” src=”http://www.site.com/jquery/jqwidgets/jqxpanel.js”></script>
<script type=”text/javascript” src=”http://www.site.com/jquery/jqwidgets/jqxcalendar.js”></script>
<script type=”text/javascript” src=”http://www.site.com/jquery/jqwidgets/jqxdatetimeinput.js”></script>
<script type=”text/javascript” src=”http://www.site.com/jquery/jqwidgets/jqxcheckbox.js”></script>
<script type=”text/javascript” src=”http://www.site.com/jquery/jqwidgets/globalization/globalize.js”></script>
<script type=”text/javascript”>
$(document).ready(function () {// prepare the data
var source =
{
localdata: data,
datafields:
[
{ name: ‘naam’, type: ‘string’ },
{ name: ‘taak’, type: ‘string’ },
{ name: ‘prioriteit’, type: ‘string’}]
datatype: “array”,
url: ‘http://www.site.com/management/takenlijstdata.php’,
async: false
};var dataAdapter = new $.jqx.dataAdapter(source);
$(“#jqxgrid”).jqxGrid(
{
width: 685,
source: dataAdapter,
showfilterrow: true,
filterable: true,
selectionmode: ‘multiplecellsextended’,
columns: [
{
text: ‘naam’, filtertype: ‘textbox’, datafield: ‘naam’, width: 220
},
{ text: ‘taak’, datafield: ‘taak’, columntype: ‘textbox’, filtertype: ‘bool’, width: 67 },
{ text: ‘prioriteit’, datafield: ‘prioriteit’, filtertype: ‘textbox’, width: 210, cellsalign: ‘right’, cellsformat: ‘d’ },]
});
$(‘#clearfilteringbutton’).jqxButton({ height: 25});
$(‘#clearfilteringbutton’).click(function () {
$(“#jqxgrid”).jqxGrid(‘clearfilters’);
});
});
</script>
</head>
<body class=’default’>
<div id=”jqxgrid”>
</div>
<input style=”margin-top: 10px;” value=”Remove Filter” id=”clearfilteringbutton” type=”button” />
</body>
</html>’I get no results on this page.
Can anyone help me?
Sorry, this is the correct code…
‘<!DOCTYPE html>
<html lang=”en”>
<head>
<link rel=”stylesheet” href=”http://www.site.nl/jquery/jqwidgets/styles/jqx.base.css” type=”text/css” />
<link rel=”stylesheet” href=”http://www.site.nl/jquery/jqwidgets/styles/jqx.classic.css” type=”text/css” />
<script type=”text/javascript” src=”http://www.site.nl/jquery/scripts/jquery-1.10.2.min.js”></script>
<script type=”text/javascript” src=”http://www.site.nl/jquery/jqwidgets/jqxcore.js”></script>
<script type=”text/javascript” src=”http://www.site.nl/jquery/jqwidgets/jqxbuttons.js”></script>
<script type=”text/javascript” src=”http://www.site.nl/jquery/jqwidgets/jqxscrollbar.js”></script>
<script type=”text/javascript” src=”http://www.site.nl/jquery/jqwidgets/jqxmenu.js”></script>
<script type=”text/javascript” src=”http://www.site.nl/jquery/jqwidgets/jqxdata.js”></script>
<script type=”text/javascript” src=”http://www.site.nl/jquery/jqwidgets/jqxgrid.js”></script>
<script type=”text/javascript” src=”http://www.site.nl/jquery/jqwidgets/jqxgrid.selection.js”></script>
<script type=”text/javascript”>
$(document).ready(function () {
// prepare the data
var source =
{
datatype: “json”,
datafields: [
{ name: ‘taaknummer’, type: ‘string’},
{ name: ‘naam’, type: ‘string’},
{ name: ‘taak’, type: ‘string’},
{ name: ‘prioriteit’, type: ‘string’},
{ name: ‘datum’, type: ‘string’}
],
url: ‘takenlijstdata.php’,
cache: false
};var dataAdapter = new $.jqx.dataAdapter(source);
$(“#jqxgrid”).jqxGrid(
{
source: dataAdapter,
theme: ‘classic’,
columns: [
{ text: ‘Company Name’, datafield: ‘taaknummer’, width: 250},
{ text: ‘ContactName’, datafield: ‘naam’, width: 150 },
{ text: ‘Contact Title’, datafield: ‘taak’, width: 180 },
{ text: ‘Address’, datafield: ‘prioriteit’, width: 200 },
{ text: ‘City’, datafield: ‘datum’, width: 120 }
]
});
});
</script>
</head>
<body class=’default’>
<div id=”jqxgrid”></div>
</body>
</html>
‘Hi kbloem,
What kind of data returns your “takenlijstdata.php” file? Could you paste it or just a sample data similar to your real data so we can test your data binding locally.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Hi Peter,
this is the data that is returned…
[{“taaknummer”:”63″,”naam”:”Kenny”,”taak”:”Murdered: Soul Suspect voor Xbox One en PS4 aanmaken”,”prioriteit”:”Laag”,”datum”:”06-02-2014″},{“taaknummer”:”65″,”naam”:”Kenny”,”taak”:”Screenshots, Reviews, hoesje toevoegen voor Tomb Raider “,”prioriteit”:”Hoog”,”datum”:”06-02-2014″},{“taaknummer”:”64″,”naam”:”Massai”,”taak”:”Features tomb raider aanpassen naar PS4 en Xbox One (toevoegen aan platform)”,”prioriteit”:”Hoog”,”datum”:”06-02-2014″},{“taaknummer”:”66″,”naam”:”Kenny”,”taak”:”Killer Instinct Xbox One aanmaken”,”prioriteit”:”Middel”,”datum”:”06-02-2014″},{“taaknummer”:”67″,”naam”:”Massai”,”taak”:”Features Killer instinct Xbox One kijken of ze er zijn”,”prioriteit”:”Middel”,”datum”:”06-02-2014″},{“taaknummer”:”68″,”naam”:”Kenny”,”taak”:”Warframe aanmaken voor PS4 en PC”,”prioriteit”:”Hoog”,”datum”:”06-02-2014″},{“taaknummer”:”69″,”naam”:”Massai”,”taak”:”Features van Warframe bij elkaar zoeken”,”prioriteit”:”Middel”,”datum”:”06-02-2014″},{“taaknummer”:”73″,”naam”:”Kenny”,”taak”:”Filter op nieuwsarchief”,”prioriteit”:”Middel”,”datum”:”07-02-2014″},{“taaknummer”:”72″,”naam”:”Kenny”,”taak”:”Mass Effect 4 toevoegen”,”prioriteit”:”Middel”,”datum”:”06-02-2014″},{“taaknummer”:”74″,”naam”:”Kenny”,”taak”:”Releasekalender”,”prioriteit”:”Middel”,”datum”:”07-02-2014″},{“taaknummer”:”75″,”naam”:”Kenny”,”taak”:”releasecheck”,”prioriteit”:”Hoog”,”datum”:”07-02-2014″},{“taaknummer”:”76″,”naam”:”Kenny”,”taak”:”url uniek maken”,”prioriteit”:”Heel Hoog”,”datum”:”07-02-2014″},{“taaknummer”:”77″,”naam”:”Kenny”,”taak”:”apache redirects”,”prioriteit”:”Heel Hoog”,”datum”:”07-02-2014″},{“taaknummer”:”79″,”naam”:”Kenny”,”taak”:”Captcha images “,”prioriteit”:”Hoog”,”datum”:”07-02-2014″}]
And this is the code i use to get that data..
$query = "SELECT * FROM takenlijst"; $from = 0; $to = 999; $query .= " LIMIT ".$from.",".$to; $result = mysql_query($query) or die("SQL Error 1: " . mysql_error()); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $taken[] = array( 'taaknummer' => $row['taaknummer'], 'naam' => $row['naam'], 'taak' => $row['taak'], 'prioriteit' => $row['prioriteit'], 'datum' => $row['datum'] ); } echo json_encode($taken);
Hi kbloem,
Please, find below a working sample based on your code:
<!DOCTYPE html> <html lang="en"> <head> <title id='Description'>This example shows how to create a Grid from Array data.</title> <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" /> <script type="text/javascript" src="../../scripts/jquery-1.10.2.min.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxmenu.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxlistbox.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxdropdownlist.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.sort.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.filter.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.selection.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.columnsresize.js"></script> <script type="text/javascript" src="../../scripts/demos.js"></script> <script type="text/javascript"> $(document).ready(function () { // prepare the data var source = { datatype: "json", datafields: [ { name: 'taaknummer', type: 'string'}, { name: 'naam', type: 'string'}, { name: 'taak', type: 'string'}, { name: 'prioriteit', type: 'string'}, { name: 'datum', type: 'string'} ], url: 'data.txt', cache: false }; var dataAdapter = new $.jqx.dataAdapter(source); $("#jqxgrid").jqxGrid( { source: dataAdapter, columns: [ { text: 'Company Name', datafield: 'taaknummer', width: 250}, { text: 'ContactName', datafield: 'naam', width: 150 }, { text: 'Contact Title', datafield: 'taak', width: 180 }, { text: 'Address', datafield: 'prioriteit', width: 200 }, { text: 'City', datafield: 'datum', width: 120 } ] }); }); </script> </head> <body class='default'> <div id="jqxgrid"></div> </body> </html>
Where data.txt is:
[{"taaknummer":"63","naam":"Kenny","taak":"Murdered: Soul Suspect voor Xbox One en PS4 aanmaken","prioriteit":"Laag","datum":"06-02-2014"},{"taaknummer":"65","naam":"Kenny","taak":"Screenshots, Reviews, hoesje toevoegen voor Tomb Raider ","prioriteit":"Hoog","datum":"06-02-2014"},{"taaknummer":"64","naam":"Massai","taak":"Features tomb raider aanpassen naar PS4 en Xbox One (toevoegen aan platform)","prioriteit":"Hoog","datum":"06-02-2014"},{"taaknummer":"66","naam":"Kenny","taak":"Killer Instinct Xbox One aanmaken","prioriteit":"Middel","datum":"06-02-2014"},{"taaknummer":"67","naam":"Massai","taak":"Features Killer instinct Xbox One kijken of ze er zijn","prioriteit":"Middel","datum":"06-02-2014"},{"taaknummer":"68","naam":"Kenny","taak":"Warframe aanmaken voor PS4 en PC","prioriteit":"Hoog","datum":"06-02-2014"},{"taaknummer":"69","naam":"Massai","taak":"Features van Warframe bij elkaar zoeken","prioriteit":"Middel","datum":"06-02-2014"},{"taaknummer":"73","naam":"Kenny","taak":"Filter op nieuwsarchief","prioriteit":"Middel","datum":"07-02-2014"},{"taaknummer":"72","naam":"Kenny","taak":"Mass Effect 4 toevoegen","prioriteit":"Middel","datum":"06-02-2014"},{"taaknummer":"74","naam":"Kenny","taak":"Releasekalender","prioriteit":"Middel","datum":"07-02-2014"},{"taaknummer":"75","naam":"Kenny","taak":"releasecheck","prioriteit":"Hoog","datum":"07-02-2014"},{"taaknummer":"76","naam":"Kenny","taak":"url uniek maken","prioriteit":"Heel Hoog","datum":"07-02-2014"},{"taaknummer":"77","naam":"Kenny","taak":"apache redirects","prioriteit":"Heel Hoog","datum":"07-02-2014"},{"taaknummer":"79","naam":"Kenny","taak":"Captcha images ","prioriteit":"Hoog","datum":"07-02-2014"}]
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Hello PEter,
i just tested the data.txt and that seems to work. However, when i use a php file for the results i get no data. Any idea?
Hi kbloem,
I suggest you to check on your side whether the path to your PHP file is correct and whether it returns the data correctly.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHelp i still need help with this.
I followed the manuals and everything seems correct. When i replace
url: 'data.txt',
withurl: 'takenlijstdata.php',
i get no results while they are both in the same folder. Even when i use the full path to the file i still get no data.Could you have another look?
Thanks!
Hi kbloem,
For the Grid, it does not matter whether the url points to .txt or .php file. If the .php returns the Data in the way data.txt does, the Grid will display it. Unfortunately, remotely I would not be able to help more about that.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comProblem solved. I had some wrong code in one of the files.
Thanks Peter!
-
AuthorPosts
You must be logged in to reply to this topic.