jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Do you have a simple JSON Example
Tagged: datagridview control, jquery datagridview
This topic contains 3 replies, has 3 voices, and was last updated by Peter Stoev 10 years, 12 months ago.
-
Author
-
I am trying to use something like this from the northwind database… Should this work or is the extra column names by id name making this fail?
Data…
$preparedStatement = $conn->prepare(“SELECT CustomerID, CompanyName, ContactName FROM Customers limit 2”);
$preparedStatement->execute();
$result = $preparedStatement->fetchAll();
echo json_encode($result);Results…
[{“CustomerID”:”ALFKI”,”0″:”ALFKI”,”CompanyName”:”Alfreds Futterkiste”,”1″:”Alfreds Futterkiste”,”ContactName”:”Maria Anders”,”2″:”Maria Anders”},{“CustomerID”:”ANATR”,”0″:”ANATR”,”CompanyName”:”Ana Trujillo Emparedados y helados”,”1″:”Ana Trujillo Emparedados y helados”,”ContactName”:”Ana Trujillo”,”2″:”Ana Trujillo”}]Javascript…
$(document).ready(function () {
// prepare the data
var source =
{
datatype: “json”,
datafields: [
{ name: ‘CustomerID’},
{ name: ‘CompanyName’},
{ name: ‘ContactName’},
],
url: ‘data.php’
};var dataAdapter = new $.jqx.dataAdapter(source);
$(“#jqxgrid”).jqxGrid(
{
source: source,
theme: ‘classic’,
columns: [
{ text: ‘CustomerID’, datafield: ‘CustomerID’, width: 200},
{ text: ‘CompanyName’, datafield: ‘CompanyName’, width: 200 },
{ text: ‘ContactName’, datafield: ‘ContactName’, width: 200 }
]
});
});Hi David,
Yes, we have 3 simple JSON samples.
– http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/bindingtojson.htm?classic
– http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/bindingtojsonusingphp.htm?classic
– http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/bindingtojsonstring.htm?classicBest Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter, please could you provide the source code for these three examples?
Thanks. MaxHi Max,
The samples are in the download package(demos/jqxgrid folder). Also the sources are available online – go to Demos, each Demo has View Source tab. Another approach is to right-click after opening a sample and click “View page source” item of your Browser’s Context Menu.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.