Integration of Cakephp and JqGrid (2)
May 8th, 2009
As requested, I have made a working copy of cakephp+jqgrid integration.
Note: This copy is built on cakephp 1.2
And you can get it from HERE.
Please read “readMe.txt” inside the folder, because there is a few configurations you need to set up before you can run it.
After you set up the demo, you should be able to see a grid table similar to this:

If you encounter any problems, please let me know , I will be very happy to help out.
And happy cake ~~!!

Oh great, thank you very much.
I think this will greatly aid many people.
The example is really useful!
okay, i really appreciate all the work done!
This helps me a lot the get around things much easier!
I downloaded your example, and tried to copy the relevant files into a new cakephp setup.
This means:
apples_controller.php
apples/
index.ctp
indextable.ctp
apple.php model (and of course getting the database + fields)
and all the relevant files in the webroot
(some css and the jqgrid javascript folder)
everything works well, i can even add data items to my database (by clicking on the icon)
but non of them shows up in my grid, i get an:
Type: parsererror; Response: 200 OK
error!
what did i miss? is there anything special to it?
cheers!
@Manuel
okay, it all comes down to:
you should set debug mode in cakephp to max 1!
@Manuel
Yes, As in debug mode 2/3,it will append sql information into the page.
and that will cause an invalid XML data.
Thank you for this great script. it works very well.
Hi have used the JQgrid in one of my pages and made some changes so that the grid reflects to one of my tables. I have changed the debug mode to 0.
Now also I get error Type: parsererror; Response: 200 OK and the grid is not at all loading.
I have checked the response data with that of ur demo/apples using firebug and they look the same.
Am I missing some thing….
@Sijo
It could be all possible reasons.
Would you mind posting your index page which invokes jqgrid javascript here ?
Well this is my index page for the controller UserhomeController.
link(’jqgrid/jquery’);
echo $javascript->link(’jqgrid/jqGrid’);
echo $javascript->link(’jqgrid/js/jqModal’);
echo $javascript->link(’jqgrid/js/jqDnR.js’);
echo $html->css(’jqgrid/themes/jqModal’);
echo $html->css(’jqgrid/themes/coffee/grid’);
?>
jQuery(document).ready(function(){
// Functions to load Leads List.
jQuery(”#JQueryLeadList”).jqGrid({
url:’url(’/userhome/indexLeadsList’) ?>’,
datatype: ‘xml’,
mtype: ‘GET’,
colNames:['Id'],
colModel :[
{name:'id', index:'id', width:200},
],
pager: jQuery(’#pager’),
rowNum:10,
rowList:[10,20,30],
sortname: ‘id’,
sortorder: ‘desc’,
multiselect: false,
viewrecords: true,
imgpath: ‘/intacademy/app/webroot/css/jqgrid/themes/coffee/images’,
caption: ‘Lead FollowUps’,
editurl:”,
height:’100′,
loadError : function(xhr,st,err) { jQuery(”#rsperror”).html(”Type: “+st+”; Response: “+ xhr.status + ” “+xhr.statusText); },
onSelectRow: function(ids) { }
});
jQuery(”#list”).navGrid(”#pager”,{edit:false,add:false,del:false});
});
My controller is UserHomeController and the list that i an retrieving is that of ‘Lead’ would that be a reason…
Well when i did not get that mine working, I tried ur example of ‘Apple’ in my application. Then it is working perfectly.. That where i am stuck.
@Sijo
Is it loading xml from “/userhome/indexLeadsList” correctly and did you check whether all files needed being loaded correctly?
you may check from firebug.
If you need further assist, you can email me your App. I could help check .
Well I have checked with firebug and the response is all OK.
The format of the XML that is raised is also correct all using firebug.
Since I am not using DatePicker and ColorPicker i have removed the corresponding links and function. All others are loading accordingly.
@Sijo
I have sent you a mail and would like to help out.
i have same problem with Sijo
can u tell me which files needed to get this thing work?
@bayu
If you are getting error Type: parsererror; Response: 200 OK.
Mostly it is due to invalid XML format.
You may check on two aspects:
1st: To check your xml content through Firebug to make sure it is getting correct xml file (without cakephp appended data)
2nd: Make sure you have put your text data into < ![CDATA[ ]]>.
Regards.
Let me know if I solved your problem.
Did someone try to use json instead of XML? maybe using json, the tables will load faster… but until now, i couldn´t make it work with json
I am using only jqGrid with JSON and MySQL and i have finaly made it, after a lot of hours put into it.
PS: i am not javascript nor SQL advanced programer.
@Daniyel
Congrats~!
Hi,
I have one problem.
I am getting this error
Undefined index: page [APP\\controllers\\apples_controller.php, line 40]
what did i miss? coz I just get nothing (blank window)
i\’m using easyphp 5.3.0
@dazn
Please follow the installation guide in readMe.txt
cheers.
I am still getting a blank page even though I have made all required configuration.
I am getting this error.
jQuery(”#list”).jqGrid is not a function
I have included in default.ctp
@Nams Check from firebug to see if jqGrid js class file is loaded or not.