Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9288547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T19:56:19+00:00 2026-06-18T19:56:19+00:00

I am programming in php, I want to take an array I have (which

  • 0

I am programming in php,
I want to take an array I have (which is extracted from mysql result set), convert it to JSON and then use it in dojox.grid.DataGrid.

I got an idea from this link:

I used the following on the array (in a file called getJSON.php)

echo $ajax = "{identifier: 'db_id', 'items':".json_encode($array)."}";

Then I try doing this (in my main page):

var store = new dojo.data.ItemFileWriteStore({ url: 'getJSON.php' });

Everything else is exactly as the Dojo documentation specifies.
The grid shows up, but doesn’t load the data and instead writes Sorry, an error occurred

Does anyone know the reason? Hopefully I gave you enough to go on.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T19:56:20+00:00Added an answer on June 18, 2026 at 7:56 pm

    i don’t use ItemFileWriteStore for that ! They changed a lot since Dojo 1.6 , so maybe you looked at something not up to date.

    Try this code:

    // Load the neccessary components (This is dojo with AMD ) !

    require([“dojo/aspect”,’dojo/_base/lang’, ‘dojox/grid/DataGrid’
    ,’dojo/dom’ , ‘dojo/store/JsonRest’,’dojo/data/ObjectStore’,
    ‘dojo/domReady!’],

    function(aspect,lang, DataGrid, dom,JsonRest,ObjectStore){ // Map components to vars…

    var store = new JsonRest({    
          target: "getJSON.php" // Use a URL that you can open up in a browser.
      });
    
    
    /*layout for the grid, you will have to adapt this to your columns !!!*/
    var layout = [[
      {'name': 'Filename', 'field': 'documentName', 'width': '300px'},
      {'name': 'Size', 'field': 'fileSize', 'width': '100px'},
      {'name': 'Id', 'field': 'id', 'width': '200px'}
    ]];
    
    dataStore=ObjectStore({objectStore: store}); // Transform to Objectstore !
    
    /*Now we create a new grid*/
    var grid = new DataGrid({
        id: 'grid',
        store:dataStore, // Connect the store
        autoWidth:false,
        structure: layout, // Connect the layout
        rowSelector: '0px'});
    
    
    grid.placeAt("yourTargetDivId"); // Has to be an existing DOM Element with id !
    grid.startup(); // START IT !
    

    });

    Please try this code by echoing something simple like this first:

    echo ‘[{“id”:”1″,”fileSize”:”100kb”,”documentName”:”Lucian !”},
    {“id”:”2″,”fileSize”:”900kb”,”documentName”:”Pew Pew !”}]’;

    And after that with your own JSON…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Programming Language I am using : PHP I have 30 results from database, which
I'm new to PHP programming and have poor knowledge about it, but I want
I am programming in PHP mysql. I have recently got into OOP programming. So
I am programming in PHP / MySQL / Javascript. I have a list of
I'm just starting PHP programming as you can tell. I want the results of
Quick background: I'm programming in PHP, I have a domain model with a separate
hello I'm new to PHP programming and I migrated from ASP .net to PHP..
I have recently started programming in PHP. I am building a cart in PHP.
I'm quite new to programming in PHP and I might have some simple problems,
I am a beginner to programming in PHP and HTML. I have made a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.