jQWidgets Forums
jQuery UI Widgets › Forums › Grid › how to create a grid from a link with a quertystring?
Tagged: querystring dynamicquery
This topic contains 2 replies, has 2 voices, and was last updated by xetere 12 years, 3 months ago.
-
Author
-
Hi, I am a newbie in jqWidgets and also JQuery so if this is obvious, apolgies.
We have a page on our private Intranet that I want to show a grid depending on what vendor is selected from a list. List of links has querystring (?id=) so that results will show depending on vendor.
I would like to know how to get the value of the fields in the GET response in the page that is part of url: in the part where you prepare the data. For example url: ‘page.php’
Nothing seems to work. it doesn’t seem
Interestingly if I use the include() command and include the url like include(‘page.php’); then I get the JSON data back but of course it is simple text at the beginning of the page (where I put the includes)So basically if I click on a link that is http://www.foo.com/listoffoos.php?fooid=43
I would like the fooresults.php to show results only when fooid = 43
If I use include in fooresults.php and include the url: ‘getfoo.php’ I will get the correct results, of course as a string at beginning of page.
I will NOT get results in the grid. I will get the grid. I hope I am being clear here, I fear not.
I wish I could show you but it is on my company’s private Intranet, so what follows is code. No laughing at my code 😉php on results hage
here is my initialization
$(document).ready(function () {
// prepare the data
var source =
{
datatype: “json”,
datafields: [
{ name: ‘docid’},
{ name: ‘docname’},
{ name: ‘docurl’},
{ name: ‘doctype’},
{ name: ‘doccat’},
{ name: ‘docroworder’ },],
url: ‘../includes/docsbyawardjqx.php’
};// initialize jqxGrid
$(“#jqxgrid”).jqxGrid(
{
width:910,
source: source,
theme: ‘classic’,
sortable: true,columns: [
{ text: ‘Document ID’, datafield: ‘docid’, width: 95},
{ text: ‘Document Name’, datafield: ‘docname’, width: 95 },
{ text: ‘URL’, datafield: ‘docurl’, width: 125 },
{ text: ‘Doc type’, datafield: ‘doctype’, width: 125 },
{ text: ‘Category’, datafield: ‘doccat’, width: 105},
{ text: ‘Row order’, datafield: ‘TravelEndDate’},]
});
});Here is page that calls db.
$row[‘docid’],
‘docname’ => $row[‘docname’],
‘docurl’ => $row[‘docurl’],
‘doctype’ => $row[‘doctype’],
‘doccat’ => $row[‘doccat’],
‘docroworder’ => $row[‘docroworder’]
);
}
echo json_encode($documents);
}
?>Hi xetere,
I guess that in your PHP script, depending on your custom parameter, you should return a different JSON result. For getting the value of a variable in a PHP script, take a look here: http://www.w3schools.com/php/php_get.asp.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comThanks.
I think the problem is that the url that I point to when I initialize the widget (let’s say whatever.php) will return null as either $_GET or even $_SESSION if I set $_SESSION[‘id’] to $_GET[‘id’], but if I write include(‘whatever.php’); in the head of the page that will display the grid results, I get the results (of course as text up top) – then whatever.php seems to recognize the $_GET or $_SESSION variables.so my naive assumption is that if there is not an explicit line of code INCLUDEing the page in the url call when I initialize the widget, then the server doesn’t see that page isn’t part of the session and thus won’t get $_GET or $_SESSION?
Does that make sense?
PS using php 5.4 with IIS 7.5 and pointing to MSSQL server db – that has never been a problem. Your widgets work great BTW!!
It’s just this one thing and I am sure it is me not getting something. -
AuthorPosts
You must be logged in to reply to this topic.