Dojo grid in Zend Framework: Creating nice and cool grid in php using Zend Framework and Dojo

8 Jan

“Create new version here”.http://zendgeek.blogspot.com/2009/07/create-dojo-grid-in-zend-framework-nice.html

About a month or two earlier when I used dojo calendar in my application and write article about the Zend Framework and dojo I was wondering why zend make collaboration with zend. But today when I created a grid using zend dojo I feel the real power of the dojo in Zend framework. In this article I am going to give a simple example and create a grid using Zend framework and dojo.

At the end of this tutorial we will have a grid like the following

Dojo Grid in Zend Framework

Dojo Grid in Zend Framework

So let’s feel the power of dojo in zend.

First execute the following query for creating a table.

CREATE TABLE ‘jobs’ (

‘id’ int(11) NOT NULL auto_increment,

‘title’ varchar(50) NOT NULL,

‘description’ text,

‘posted_date’ datetime default NULL,

PRIMARY KEY  (‘id’)

)

This will create a table in your database.

Create a model in your models directory and write the following code in it

<?php

class Jobs extends Zend_Db_Table_Abstract

{

protected $_name=’jobs’;

public function getJobsData()

{

$select = $this->_db->select()

->from($this->_name);

$results = $this->getAdapter()->fetchAll($select);

return $results;

}

}

?>

and save this table as Jobs.php

In the code above, we first extend our model from Zend_Db_Table_Abstract, define its name and define our custom function getJobsData() that fetch all the rows in the jobs table. We return the results as an array.

Next create a controller JobsController in you controller’s directory and place the following code in it.

<?php

class JobsController extends Zend_Controller_Action

{

public function  viewAction()

{

}

public function  recordsAction()

{

$jobs = new Jobs();

$data= $jobs->getJobsData();

$dojoData= new Zend_Dojo_Data(‘id’,$data,’id’);

echo $dojoData->toJson();

exit;

}

}

In the above code we create two action view and records. We have placed nothing in the view action. In the recordsAction, we create an instance of Jobs model class.and then call its getJobsData() method which will give us an array of records. Next we create an instance of Zend_Dojo_Data() and give the fetched data to it. And finally we echo the data converted it into the Json.

We don’t need to create a view for the records action because we have placed exit it the end of this action which will stop rendering of the view. As we will call this action form our grid view template page so no need to define phtml file for it.

However we will need to create template file for our viewAction. In scripts/views/ directory create view.phtml file and place the following code in it.

<?php

Zend_Dojo_View_Helper_Dojo::setUseDeclarative();

$this->dojo()->setLocalPath(‘http://localhost/Zend/js/dojo/dojo/dojo.js&#8217;)

->addStyleSheetModule(‘dijit.themes.tundra’)

->addStylesheet(‘http://localhost/Zend/js/dojo/dojox/grid/_grid/tundraGrid.css&#8217;);

echo $this->dojo();

?>

<script type=”text/javascript”>

dojo.require(“dojox.data.QueryReadStore”);

dojo.require(“dojox.grid.Grid”);

dojo.require(“dojo.parser”);

</script>

<body class=”tundra”>

<div dojoType=”dojox.data.QueryReadStore” jsId=”activeStore”, url=”records”></div>

<div dojoType=”dojox.grid.data.DojoData” jsId=”model” rowsPerPage=”20″ store=”activeStore”></div>

<table id=”activePastes” dojoType=”dojox.grid.Grid” model=”model” style=”height:300px; width:700px;”>

<thead>

<tr>

<th field=”id”>Id</th>

<th field=”title”>Title</th>

<th field=”description”>Description</th>

<th field=”posted_date”>Posted</th>

</tr>

</thead>

</table>

</body>

Keep in mind this is the main template file where we are creating our gird.

In the first statement I told zend to use declarative instead of programmatic behavior which is default. Next I set local path and add specific stylesheets. Then in the javascript code I used statement

Dojo.requre(‘dojox.data.’) etc

To include specific dojo js modules.

In the body tag I specify a class “tundra”. This is important for the stylesheet I have added.

Next tow div’s and table are  the main code for creating grid.

The first div fetch the records from the url specified. This url may be different if you fetch records form the other controller or source. Please specify valid url otherwise you will not get what you want.

The next div act as a bridge between our first div and the table. This div take data from the first div and give it to the table for display purposes.

Keep in mind that all the attributes of the div’s and table are compulsory. Removing any of the attribute may result in unvalid records or empty page. So define everything that I have defined. Once you become able to display your records, you can play with these attributes.

60 Responses to “Dojo grid in Zend Framework: Creating nice and cool grid in php using Zend Framework and Dojo”

  1. Greg January 26, 2009 at 4:19 pm #

    Edits: your div tag is unterminated
    <div dojoType=”dojox.grid.data.DojoData” ...
    and you misspelled your closing thead tag.

  2. Todd February 12, 2009 at 4:18 am #

    Thank you very much. I spent hours tinkering with Zend and dojo today. With the help of this post I finally got over the hump. I see a grid!

  3. saurabh March 13, 2009 at 11:19 am #

    i can see only the headings..i.e id title description posted when i go to localhost/jobs/view URL..and i am not able to see any records..wot things should i check?

  4. Faheem Abbas March 13, 2009 at 12:38 pm #

    I’ve seen most of the time that if we don’t use “store” properly, we only see headings. For example “QueryReadStore” in this example. you should check your paths, e.g
    dojo.require(”dojox.data.QueryReadStore”);

    Important: Check your path to local dojo.js file.
    Keep in mind that if path to dojo.js file is not properly set, you may not be able to get the dojo grid.

  5. girish March 13, 2009 at 5:54 pm #

    Hi Faheem Abbas,
    You are simply gr8. I searched all the web (except this page) for short & simple tut on grid.
    I now i finally have a grid on my page.
    thx a ton.

    keep posting such good tuts.

  6. saurabh March 14, 2009 at 9:14 am #

    still the problem isnt solved.!for the above tutorial are there any settings required in bootstrap,layout? or is this the complete working tutorial?i have modified bootstrap,layout as per your “zend framework and dojo” tutorial.please reply

  7. Faheem Abbas March 14, 2009 at 2:00 pm #

    Yes, you will need to make some configuration setting for using dojo in you Zend Framework application. please read the following article before creating grid with dojo.
    https://zendguru.wordpress.com/2008/10/27/zend-framework-and-dojo/

  8. saurabh March 16, 2009 at 9:40 am #

    i have followed exactly according to this tutorial and https://zendguru.wordpress.com/2008/10/27/zend-framework-and-dojo/ for configuring dojo grid…still i cant see any grid..now i get “dojo loaded” message twice in my browser(i have put alert(‘dojo loaded’)in dojo.js) ..i think first is from view.phtml(job controller’s view action) and other is comming from layout.phtml..so how can i solve this problem?

  9. Faheem Abbas March 16, 2009 at 1:01 pm #

    congrats for loading dojo successfully. Now make sure that your other js files like QueryReadStore.js etc are also properly loaded. And I’ll suggest you carefully read and follow my article. If problem doesn’t solve, gemme some explanation and I’ll try to solve your problem.

  10. Jim March 17, 2009 at 3:46 am #

    Saurabh

    I had to do this in my controllers action that the datastore’s url referenced …

    // this has no associated renderer
    $this->_helper->viewRenderer->setNoRender();
    // this has no associated layout
    $this->_helper->getHelper(‘layout’)->disableLayout();

    I ultimately ended up creating base class controller for my async actions. Once I setup the above, the grid worked as I expected.

    Without the above, I was getting firebug message about SyntaxError … very generic, not helpful and I checked in to the response, and found it was not what I was expecting .. which led me to try the above to disable layouts and rendering for asynchronous calls (ie – just echo’ing results on requests)

  11. saurabh March 17, 2009 at 6:46 pm #

    Jim,
    Can u please elaborate..do u mean i should add the 2 lines u said in
    1)public function recordsAction() or
    2)view.phtml
    NOTE:my browser doesnt show any errors but neither i see grid with records…

  12. Jim March 17, 2009 at 7:18 pm #

    Saurabh

    What I did was something like this

    class MyAsyncController extends Zend_Controller_Action
    {
    public function init()
    {
    // this has no associated renderer
    $this->_helper->viewRenderer->setNoRender();
    // this has no associated layout
    $this->_helper->getHelper(’layout’)->disableLayout();
    }
    }

    then, I created my “asynchronous handlers” deriving from that controller ..

    class MyHandlerController extends MyAsyncController
    {
    public function recordsAction()
    {
    public function recordsAction()
    {
    $model = new ModelObject();
    $data = $model->getMyData();
    $dojoData = new Zend_Dojo_Data(‘MyID’, $data, ‘Mylabel’);
    echo $dojoData->toJson();
    }
    }
    }

    A thing to note, is that the grid has display issues (and retrieval of additional records) if you dont encode ‘numRows’ => totalrecords into it. It isn’t required for datasets that return fewew rows than rowsPerPage, but is if there are more.

  13. Jim March 17, 2009 at 7:19 pm #

    oops on repeated function in MyHandlerController … but I think you get the idea🙂

  14. saurabh March 18, 2009 at 6:34 am #

    friends,
    Now I am able to retrieve the records,but they are just scattered and I am not able to see the GRID yet inspite of getting dojo loaded message!

    Jim,
    your settings stopped entire rendering(i get blank page)..so commented out those lines

  15. saurabh March 20, 2009 at 6:58 am #

    thanks everyone for help,my problem is solved,I can see the grid now.

  16. Ashley Kitson March 24, 2009 at 11:36 am #

    Faheem,
    1st, thanks for the tutorial. It’s a real help when the documentation at dojo central is so sparse.

    I think I’m missing something as I can’t get data into the grid

    My layout looks like this:

    Id
    Title
    Send Status
    Send Date

    I can’t yet see any output in the table yet, but it does display the table structure.

    the URL /zwmail/adminjson/viewmitems/ does work. I tested it by a direct call using
    function viewList(idList) {
    var data = {‘idList’:idList};

    dojo.xhrGet( {
    url: “/zwmail/adminjson/viewmitems/”,
    handleAs: “json”,
    content: data,
    load: function(responseObject, ioArgs) {
    //check return here in firebug
    return responseObject;
    }
    // More properties for xhrGet…
    });
    }

    The dojo integration is working as I am able to display a tabbed page and pull in other data items via dojo.xhrGet() calls already.

    Also, I need to be able to update the table dynamically, i.e. when a parent record id changes. What javascript do I need to update the table on the fly? A demonstration of that would round your article off nicely.

    Thanks.

  17. Ashley Kitson March 24, 2009 at 11:39 am #

    Oops – the layout should be (trying with pre tags

    Id
    Title
    Send Status
    Send Date

  18. Ashley Kitson March 24, 2009 at 11:39 am #

    Nope, that didn’t work – any suggestions for embedding html in one of these comments?

  19. Faheem Abbas March 24, 2009 at 3:51 pm #

    If table structure is there, my question would be.
    Is the theme applied to that table. I mean tundra theme.
    If yes then you have problem with setting your url.
    dojo.xhrGet( {
    url: “/zwmail/adminjson/viewmitems/”,
    handleAs: “json”,
    content: data,
    load: function(responseObject, ioArgs) {
    //check return here in firebug
    return responseObject;
    }
    url must point to place, where you want it to be.
    Typing url and using it from a page may behave differently.so it would be better if you give your absolute path like
    “http://…” and check whether grid display the data.

  20. Ashley Kitson March 24, 2009 at 4:15 pm #

    typing in a fqdn doesn’t work either

    I cannot get the view template source code into this editor to show you. (bah humbug). tell me how you do it and I’ll post it 2morrow.

    Thanks
    A

  21. Ashley Kitson March 25, 2009 at 3:47 pm #

    Faheem, thanks for your patience. OK first off, the action script does get called by the view template. Here’s another example.

    1/ view script (Just so I can get this displaying in these comments I’m replacing the xhtml brackets with [ and ])

    [div dojoType=”dojox.data.QueryReadStore” jsId=”subsStore”, url=”/zwmail/adminjson/viewsubs/”][/div]
    [div dojoType=”dojox.grid.data.DojoData” jsId=”subsModel” rowsPerPage=”20″ store=”subsStore”][/div]
    [table id=”zwmail_admin_subsGrid” dojoType=”dojox.grid.Grid” model=”subsModel” style=”height:300px; width:300px;”]
    [thead]
    [tr]
    [th field=”id”]Id[/th]
    [th field=”lstName”]List Name[/th]
    [th field=”dateJoined”]Start Date[/th]
    [th field=”dateLeft”]End Date[/th]
    [/tr]
    [/thead]
    [/table]

    2/ action script

    $dojoData = new Zend_Dojo_Data(‘subId’,$arrItem); //id must be set to an item in the array
    $dojoData->setMetadata(‘numRows’,count($arrItem));//according to ZF docs dojo.data.grid reques numrows
    $dojoData->setLabel(‘subsModel’); //maybe this does something?
    echo $dojoData->toJson();

    3/ response data returned by action script (viewable via firebug)

    {“identifier”:”subId”,”items”:[{“subId”:”7″,”lstName”:”ZWMail Newsletter”,”dateJoined”:”23\/03\/2009″
    ,”dateLeft”:”23\/03\/2009″}],”numRows”:1,”label”:”subsModel”}

    But the table doesn’t display on screen.

    TIA

  22. Faheem Abbas March 26, 2009 at 5:56 am #

    Ashley Kitson,
    It seems that you are not following what i have done in the above article.
    Please tell me why don’t you want to follow my example and then play with the grid and make changes once you succeeded.
    From the above code I cannot guess where are you putting all the code. In single file or in different files.
    Please give some explanation about

    $dojoData = new Zend_Dojo_Data(’subId’,$arrItem); //id must be set to an item in the array
    $dojoData->setMetadata(’numRows’,count($arrItem));//according to ZF docs dojo.data.grid reques numrows
    $dojoData->setLabel(’subsModel’); //maybe this does something?
    echo $dojoData->toJson();

    where this code reside?

  23. Vishal March 28, 2009 at 10:28 am #

    Thanks a lot abbbas for nice article please also tell how to obtain the data of a row on clicking but please in Zend 1.7

  24. Marta April 11, 2009 at 5:09 pm #

    Hi.

    I followed your example, but in the end I have only two checkboxes displayed instead of my grid.
    Is this a known problem?
    The first div does not fetch data from url (if i put some bug in the code no error is reported), but I’m quite sure the url is ok and if I check it in browser correct json data are displayed.

  25. Marta April 11, 2009 at 6:51 pm #

    Hmm, it seems that proper stylesheet is missing. I managed to make working example with DojoGrid (had the same problem):

    var storeM = new dojox.data.QueryReadStore({url:'baseUrl;?>/index/records'});

    ...

    with imported dojox/grid/resources/tundraGrid.css

    It doesn’t work for your example.
    Could you write what css files are you using?
    Thanks.

  26. Marta April 11, 2009 at 7:13 pm #

    Sorry, please forget about previous comment, I need to rest…🙂

  27. Faheem Abbas April 13, 2009 at 5:53 am #

    you might be missing

    "<body class=tundra">

    in your code.

  28. marc April 23, 2009 at 3:50 am #

    Hello

    Thank you for the code.

    It is working but the load time is terribly slow do know what might be causing that when It seems to be the dojo.require(”dojox.grid.Grid”); that is causing the slow down.

    Thanks

  29. Faheem Abbas April 23, 2009 at 6:22 am #

    Read my article on how to improve dojo performance.
    https://zendguru.wordpress.com/2009/01/07/improve-dojo-performance-in-zend-framework/

  30. Chitta Ranjan April 25, 2009 at 4:55 am #

    Nice article. Keep it up.

    How can we implement searching and paging in this grid like extjs grid.

    Thanks.

  31. Ivan May 5, 2009 at 9:02 am #

    Hi,
    I managed to rend a grid but I can’t see any data inside it. Seems like I don’t get any data at all from my recordsAction. How can I understand if the grid gets any data at all, and the most important for me is to know if it calls the recordsAction at all.

  32. ZfNoob May 15, 2009 at 2:38 am #

    me too =(

  33. ZfNoob May 15, 2009 at 3:25 am #

    IVAN you should edit the url=”records” to your records path…
    For example I have it here url=”/my_project/public/jobs/records”
    🙂

  34. dhayal June 5, 2009 at 8:21 am #

    Hi Mr Faheem Abbas,
    I read most of your articles. Really very useful for me.. I am new to Zend Framework. with your articles i am improving my skills thanks… This grid is very nice…

    Could u give me your Email?

  35. dhayal June 5, 2009 at 9:09 am #

    http://download.dojotoolkit.org/release-1.2.0/dojo-release-1.2.0/dojox/grid/tests/test_yahoo_search.html

    in the above two grids, they provided in line edit and search inside grid…This would provide a strong user interface if we apply this in real world application,Hope if we try we can achieve it using ZendFramework …

  36. dhayal June 5, 2009 at 9:15 am #

    this link will display all

    http://download.dojotoolkit.org/release-1.2.0/dojo-release-1.2.0/dojox/grid/tests/

  37. Gustavo June 17, 2009 at 7:27 pm #

    How can I do a CRUD application using the dojo grid?

  38. Naimesh August 3, 2009 at 12:17 pm #

    First of all Thanks Faheem for this efforts.

    Well I tried creating as mentioned in your code as also setup the dojo as per link mentioned above, but I am just able to display labels in blank page no data or grid.

    I tried this on zend framework 1.8.4

    Please find my code below :

    My Bootstrap :

    class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
    {
    
     protected function _initAutoload()
        {
            $autoloader = new Zend_Application_Module_Autoloader(array(
                'namespace' => 'Default_',
                'basePath'  => dirname(__FILE__),
            ));
            return $autoloader;
        }
    
        protected function _initDoctype()
        {
    //    	$view = new Zend_View();
            $this->bootstrap('view');
            $view = $this->getResource('view');
        	$view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper');
        	$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
        	$viewRenderer->setView($view);
        	Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
        }
       
    }
    

    My view.phtml script :

    //echo $this->baseUrl. "/public/js/dojo/dojo.js";
    // "http://localhost/Zend/js/dojo/dojo/dojo.js"  
    // "http://localhost/Zend/js/dojo/dojox/grid/_grid/tundraGrid.css"
        Zend_Dojo_View_Helper_Dojo::setUseDeclarative();
        $this->dojo()->setLocalPath("http:localhost:81/dailywork/public/js/dojo/dojo.js")
        ->addStyleSheetModule("dijit.themes.tundra")
        ->addStylesheet("http:localhost:81/dailywork/public/js/dojox/grid/_grid/tundraGrid.css" );
        echo $this->dojo();
    ?>
     
        dojo.require('dojox.data.QueryReadStore');
        dojo.require('dojox.grid.Grid');
        dojo.require('dojo.parser');
      
      
    
       
         
           
             
    			Id
    			Title
    			Description
    			Posted    	
        	
        
        
    

    I tried putting full URL as shown in above codes also. I did also try with asynchronous things mentioned by Jim.

    I did copy subfolders in /externals folders of zend framework downloaded. I copied dijit, dojo and dojox folders in /public/js folder. My index.php is in root above public directory.

    I also tried opening the full URL’s for dojo.js and .css files pasting in browser, it is opening it, so URL is correct.

    Please help me on this.

    Thanks In Advance !

    Naimesh

  39. Naimesh August 3, 2009 at 1:58 pm #

    I also checked in IE now, and it is gives javascript error, showing Dojo undefined, on view script in line Zend_Dojo_View_Helper_Dojo::setUseDeclarative();

    so seems something missing in Dojo setting.

    Please help on this.

    Naimesh

  40. Faheem Abbas August 4, 2009 at 4:10 pm #

    your path to dojo is not correct.

  41. Naimesh August 5, 2009 at 5:19 am #

    Hello ! Thanks for the prompt reply.

    Well but I did try adding following in my view and it says dojo is enabled. And direct url mentioned in setlocalpath and addstylesheet opens directly in browser.

    dojo()->isEnabled())
    {
    echo “Dojo Enabled” ;
    echo $this->dojo();
    }
    else
    echo “Dojo Not Enabled” ;?>

    And I got Dojo enabled printed but no output for $this->dojo().

    I also changed the bootstrap adding following

    protected function _initView()
    {
    // Initialize view
    $view = new Zend_View();
    $view->doctype(‘XHTML1_STRICT’);
    // $view->headTitle(‘My First Zend Framework Application’);
    $view->addHelperPath(‘Zend/Dojo/View/Helper/’, ‘Zend_Dojo_View_Helper’);

    // Add it to the ViewRenderer
    $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper(
    ‘ViewRenderer’
    );
    $viewRenderer->setView($view);
    Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);

    // Return it, so that it can be stored by the bootstrap
    return $view;
    }

    But no difference.

    Please guide me, what is wrong. I did copy everything under dojo directory in /externals to /dailywork/public/js where dailywork is my application directory and my index.php is in /dailywork.

    Thanks in Advance !

    Naimesh

  42. Faheem Abbas August 5, 2009 at 6:21 am #

    Well, you hopefully will have added dojo.js file in your header or layout file. if you are not using layout, you will need to include it in every template file. From template I mean your view.
    If you have done this, then try to open dojo.js and write an alert statement in that file. This alert should be the first statement.
    If yoru page successfully show an alert while loading then it means you have successfully included dojo in you script.

  43. Naimesh August 5, 2009 at 7:00 am #

    Well I did add alert(“I came there”) in first line of /dailywork/public/js/dojo/dojos.js but alert does not popup.

    I have disabled layout (removed layout line in application.ini) My view is directly called and scripts are written like you have mentioned. My application directory is /dailywork in my wamp/www and dojo directories are copied in /dailywork/public/js

    My bootstrap is :

    ‘Default_’,
    ‘basePath’ => dirname(__FILE__),
    ));
    return $autoloader;
    }

    protected function _initView()
    {
    // Initialize view
    $view = new Zend_View();
    $view->doctype(‘XHTML1_STRICT’);
    // $view->headTitle(‘My First Zend Framework Application’);
    $view->addHelperPath(‘Zend/Dojo/View/Helper/’, ‘Zend_Dojo_View_Helper’);

    // Add it to the ViewRenderer
    $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper(
    ‘ViewRenderer’
    );
    $viewRenderer->setView($view);
    Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);

    // Return it, so that it can be stored by the bootstrap
    return $view;
    }
    }

    My view.phtml is

    dojo()->setLocalPath(“http:localhost:81/dailywork/public/js/dojo/dojo.js”)
    ->addStyleSheetModule(“dijit.themes.tundra”)
    ->addStylesheet(“http:localhost:81/dailywork/public/js/dojox/grid/_grid/tundraGrid.css” );
    echo $this->dojo();
    ?>

    dojo.require(‘dojox.data.QueryReadStore’);
    dojo.require(‘dojox.grid.Grid’);
    dojo.require(‘dojo.parser’);

    Id
    Title
    Description
    Posted

    dojo()->isEnabled())
    {
    echo “Dojo Enabled” ;
    echo $this->dojo();
    }
    else
    echo “Dojo Not Enabled” ;?>

    My model and controller scrips are like you mentioned and table also i added like you mentioned.

    My application.ini

    [production]
    phpSettings.display_startup_errors = 0
    phpSettings.display_errors = 0
    includePaths.library = APPLICATION_PATH “/../library”
    bootstrap.path = APPLICATION_PATH “/Bootstrap.php”
    bootstrap.class = “Bootstrap”
    resources.frontController.controllerDirectory = APPLICATION_PATH “/controllers”
    resources.view[] =
    resources.db.adapter = “pdo_mysql”
    resources.db.params.host = “localhost”
    resources.db.params.username = “root”
    resources.db.params.password = “rootpass”
    resources.db.params.dbname = “dailywork”
    resources.db.isDefaultTableAdapter = true

    [staging : production]

    [testing : production]
    phpSettings.display_startup_errors = 1
    phpSettings.display_errors = 1

    [development : production]
    phpSettings.display_startup_errors = 1
    phpSettings.display_errors = 1

    I guess I mentioned everything, required for you to help me finding what is wrong here, however pls let me know, if u need something more.

    Thanks & Regards,

    Naimesh

  44. Faheem Abbas August 5, 2009 at 7:14 am #

    Do you have .htaccess file?
    I guess that .htaccess file is preventing your js file to be properly including in you view.
    You can search an article about this bug in my blog.

  45. Naimesh August 5, 2009 at 1:37 pm #

    Dear Faheem,

    Hello ! Thanks for the inputs. I did find things related to .htaccess and change mine, but still not able to see the alert.

    My original .htaccess was

    SetEnv APPLICATION_ENV development

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} -s [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ – [NC,L]
    RewriteRule ^.*$ index.php [NC,L]

    and I changed it to

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule .* index.php

    But still same issue. Please help me on this. If you need, I can give source of this sample appl. however everything I tried to copy here for your review in previous PM.

    Thanks in Advance !

    Naimesh

  46. Faheem Abbas August 6, 2009 at 5:23 am #

    specify me only the error(s) that jumps out. But one thing I can surely say that dojo isn’t working in IE8. Don’t check it in IE8.
    Anyhow specify me error so that I understand the nature of the failure.

  47. Naimesh August 6, 2009 at 6:42 am #

    Dear Faheem,

    Hello ! Well there is no error coming while running the page http://localhost:81/dailywork/jobs/view, just displaying :

    ID Title Description Posted

    Dojo Enabled

    But in IE7 in status window yellow (! Done) marks comes, double clicking on it, shows javascript error on line 15 in view.phtml which is dojo.require(‘dojo.parser’); – see in above PM my view.phtml script copied.

    Please let me know anything else you need to help me pointing the error.

    Thanks in Advance !

    Naimesh

  48. Naimesh August 6, 2009 at 6:43 am #

    Normally I use FireFox 3.0.13 but also mentioned above what happens in IE7.

    Thanks

    Naimesh

  49. Naimesh August 6, 2009 at 1:45 pm #

    Well, now I am able to see the Grid, but data is empty, ? coming in each col of the grid. wt could be the reason.

    Please see my codes in http://pastie.org/573952

    Thanks in Advance

    Naimesh

  50. Faheem Abbas August 7, 2009 at 5:46 am #

    Can you show me how your grid look like?

  51. Naimesh August 7, 2009 at 6:13 am #

    Please find the screen shot in below link

    http://rmwsolns.rajtecnicals.railsplayground.net/blankgrid.html

    Thanks in Advance !

    Naimesh

  52. Faheem Abbas August 7, 2009 at 7:09 am #

    You need to give correct url to the data store.

    <div dojoType="dojox.data.QueryReadStore" jsId="activeStore", url="/jobs/records"></div>
    

    try absolute path. like this.. http://localhost:81/dailywork/jobs/records. This is not the correct way, however it will show you records at least.
    The best way is to define baseUrl and then set this path.

  53. Naimesh August 7, 2009 at 7:37 am #

    Well I did try that and I already did so before also but no difference.

    Thanks in Advance !

    Naimesh

  54. Naimesh August 7, 2009 at 7:57 am #

    Yea I am able to see records in grid now thanks. The problem was I required to Load Jobs using Zend_Loader::loadClass(‘Jobs’); I did so and it started showing rows in grid.

    Well actually I did use AutoLoader in my bootstrap as below, do I still need to load classes like did above for Jobs ?

    protected function _initAutoload()
    {
    $autoloader = new Zend_Application_Module_Autoloader(array(
    ‘namespace’ => ‘Default_’,
    ‘basePath’ => dirname(__FILE__),
    ));
    return $autoloader;
    }

    Thanks in Advance !

    Naimesh

  55. dguiarj August 20, 2009 at 4:08 pm #

    Hi…
    I did recommend that u replace the widget “dojox.grid.Grid” for “dojox.grid.DataGrid”
    to do that u should:
    take off the “model” object (replace it for a direct call on the “view” at the DataGrid tag by “structure” and “query” attributes)

    the grid tag would be somethigs like:


    where view should be the layer that describes table layout (js obj not model widget)

    (Also the proper require… dojo.require(“dojox.grid.DataGrid”))

  56. Umer December 29, 2009 at 7:13 am #

    Thanks Faheem

  57. Umer December 31, 2009 at 6:05 am #

    According to new version of dojo please change view.phtml as follows:

    dojo()->setLocalPath($this->BaseUrl().’/js/Dojo-new/dojo/dojo.js’)
    ->addStyleSheetModule(‘dijit.themes.tundra’)
    ->addStylesheet($this->BaseUrl().’/js/Dojo-new/dojox/grid/resources/tundraGrid.css’)
    ->addStylesheet($this->BaseUrl().’/js/Dojo-new/dojox/grid/resources/Grid.css’);
    echo $this->dojo();
    ?>

    //dojo.require(“dojox.grid.Grid”);
    dojo.require(“dojox.grid.DataGrid”);
    dojo.require(“dojox.data.QueryReadStore”);
    dojo.require(“dojo.parser”);

    Id
    Title
    Description
    Posted

  58. Antonio January 25, 2010 at 9:42 am #

    Hi dguiarj,

    Could you please repost the tag again, i seem to be having constant trouble not showing the grid, but able to pass the json data from the action.

    Thank you.

Trackbacks/Pingbacks

  1. Zend Framework and dojo-grid sorting example « Zend Framework - January 12, 2009

    […] Framework and dojo-grid sorting example In my previous post “dojo-grid-in-zend-framework-creating-nice-and-cool-grid-in-php-using-zend-framework-and-dojo” I discuss how to creat nice and cool gird using Zend framework and […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: