Forum

July 10th, 2011
You must be logged in to post Login Register

Search Forums:


 






How to integrate jqGrid with CakePHP

No Tags
UserPost

20:27
12/10/2008


myles

myles

Member

posts 7

Good Day to All!

First I would like to thank the creators of jqGrid for an awesome grid and documentation.

My question is can we use a function instead of using a php file url to

have pagination?


I mean instead of using the code snippet below:

       jQuery("#MyList").jqGrid
       ({
            url:'server.php?q=2',
            datatype: "json",

can we do something like this?

       jQuery("#MyList").jqGrid
       ({
            url:'GenerateJson()',
            datatype: "json",


Hope someone could help.

Thanks and Regards,

Myles

01:36
13/10/2008


tony

Sofia, Bulgaria

Moderator

posts 7392

Hello,

The final release have something like

datatype : function(pdata){

// call your own function here

// use addXmlData or addJSONData methods

}


Regards

Tony

For professional UI suites for PHP, ASP.NET and ASP.NET MVC visit us at our commercial products site – trirand.net – by the very same guys that created jqGrid.

02:54
13/10/2008


myles

myles

Member

posts 7

What did you mean final release? you mean version 3.3?

Can you please explain more on your sample I am a little bit confused.


All I want to do is use jqGrid in CakePHP but the problems is in CakePHP

you have to access data through a Controller or Controller Components.

And in the samples it gets data through a PHP page.


Can anybody enlighten me on this.


Thanks and Regards,

Myles


04:01
13/10/2008


tony

Sofia, Bulgaria

Moderator

posts 7392

Hello,

It is a little confused for me, but the current published version

3.3. is preview release. Final will be in Tuesday.

Regards

Tony

For professional UI suites for PHP, ASP.NET and ASP.NET MVC visit us at our commercial products site – trirand.net – by the very same guys that created jqGrid.

20:59
13/10/2008


myles

myles

Member

posts 7

To simplyfy my question,

How can I use jqGrid with CakePHP?


Thanks and Regards,

Myles

03:47
14/10/2008


tony

Sofia, Bulgaria

Moderator

posts 7392

Hello,

Since I do not know CakePHP – but if you can call direct via url a function

as of your code it is a really simple: (suppose JSON)

datatype : function(pdata){

$.ajax({

url: 'yourfunctionhere',

data: pdata,

complete : function(response,status) {

if(status=='success'){

var mygrid = jQuery(gridid)[0];

mygrid.addJSONData(eval("("+response.responseText+")"));

}

}

})

}

Hope this helps

Regards

Tony

For professional UI suites for PHP, ASP.NET and ASP.NET MVC visit us at our commercial products site – trirand.net – by the very same guys that created jqGrid.

20:50
20/10/2008


myles

myles

Member

posts 7

Thank very much for the response.

By the way with the code above how can I implement pagination and

filtering of data?


Can jqGrid pass values through the function parameters to get data for

pagination and filtering data instead of passing through the URL?


Like  this variables in the sample:

// to the url parameter are added 4 parameter
// we should get these parameter to construct the needed query
// for the pager

// get the requested page
$page = $_REQUEST['page'];
// get how many rows we want to have into the grid
// rowNum parameter in the grid
$limit = $_REQUEST['rows'];
// get index row – i.e. user click to sort
// at first time sortname parameter – after that the index from colModel
$sidx = $_REQUEST['sidx'];
// sorting order – at first time sortorder
$sord = $_REQUEST['sord'];

21:07
20/10/2008


myles

myles

Member

posts 7

I mean can I use jqGrid like the code snippet below:


datatype : function(pdata){

$.ajax({

url: 'getJsOnData(page, rows, sidx, sord)',

data: pdata,

01:18
21/10/2008


tony

Sofia, Bulgaria

Moderator

posts 7392

Hello,

That is you solution except that pdata contain all the needed pagging parameters – i.e. pdata is actually postData array.

If you can not use pdata you can do it in you function this way

datatype : function(pdata){

$.ajax({

url: 'getJsOnData(pdata.page, pdata.rows, pdata.sidx, pdata.sord)',


For professional UI suites for PHP, ASP.NET and ASP.NET MVC visit us at our commercial products site – trirand.net – by the very same guys that created jqGrid.

23:18
14/11/2008


xuding

xuding

Member

posts 36

Dude, I have just done the integration after half day trying..

Let me know if you still need help with it since thi is a old post.

01:54
12/12/2008


myles

myles

Member

posts 7

Yes if you have can have a sample in your implementation please post here.

Thanks in advance

19:58
22/01/2009


xuding

xuding

Member

posts 36

Since Cakephp follows MVC, model. and jqgrid is getting data from 

jQuery("#MyList").jqGrid
       ({
    ->        url:'server.php?q=2'  

….

so we can actually put a html helper here in 'url' .

$html->link('/myapp/tabledata').

and in myapp controller, we create a action tabledata to pull out table data , and in tabledata view, we form the xml or json data, and the basic integration is done.


similar to this ,we could do adding,editting, deleting and so on in our controller.

p/s: i am using cakephp 3.3 .

Hope you can get what I mean, i will try to write a detailed tutorial  if needed when I have time.

Enjoy cake and grid..


23:47
16/04/2009


xuding

xuding

Member

posts 36


I have wrote a simply tutorial of integration on my blog:

http://www.the-di-lab.com/?p=1


03:45
15/05/2009


myles

myles

Member

posts 7

Thanks for the effort in making a tutorial and also a sample I try it

No Tags

About the jQuery Grid Plugin – jqGrid forum

Most Users Ever Online:

215


Currently Online:

100 Guests

Forum Stats:

Groups: 1

Forums: 7

Topics: 10279

Posts: 30383

Membership:

There are 11049 Members

There have been 448 Guests

There is 1 Admin

There are 2 Moderators

Top Posters:

OlegK – 1210

markw65 – 179

kobruleht – 144

phicarre – 132

YamilBracho – 124

Renso – 118

Administrators: admin (60 Posts)

Moderators: tony (7392 Posts), Rumen[Trirand] (81 Posts)




Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information