Delphi Handbooks Collection


Delphi XE Handbook


Delphi 2010 Handbook


February 21, 2011

jqGrid in Relax

I've posted another unit of Delphi Relax, with jqGrid support, added a specific demo and updated the documentation.

I've posted another unit of Delphi Relax, with jqGrid support (the unit is RlxjqGrid.pas), added a specific demo and updated the documentation. This is the sample output:

The problem I had to face was to work around Delphi DataSnap REST Application support, as jgGrid passes HTTP params I had to "hide" and requires a "plain" JSON object as result, and not the structure used by Delphi. However, the actual server side code I had to use boils down to the following:

 





 

7 Comments

jqGrid in Relax 

 what a pity. Why do you still use 
datasnap and the horrible json library 
from codegear ? :(
Comment by henri gourvest [http://www.progdigy.com] on February 22, 00:04

jqGrid in Relax 

Henri,

  DataSnap REST support has a few very interesting 
features, from sessions management in REST calls to 
functions mapping and more.

It has also some weaknesses (but not in the JSOn 
support, that I think is OK) but I've always found a 
workaround in a limited time, so why trow away 
everything?
Comment by Marco Cantu [http://www.marcocantu.com] on February 22, 08:10

jqGrid in Relax 

Great job Marco,

We have been hoping and waiting for jqgrid support for
DataSnap.

So the jqgrid AJAX and the DataSnap AJAX do not
interfere with each other?

Thanks again,

Keith
Comment by Keith on February 22, 11:51

jqGrid in Relax 

Very nice.

Will you be adding support for Multisearch like on the
demo page.

http://www.trirand.com/blog/jqgrid/jqgrid.html

And will this design allow for master-child grids ?
Or even nested/tree grids ?

Very impressed so far..
Comment by Andrew Tierney [http://www.castlesoft.com.au] on February 22, 13:33

jqGrid in Relax 

Its now 12:50am in Australia.. Just can't tear myself
away from the relax/jqgrid demo/source.

I noticed on the jqrid site it also supports:

 Add/edit/delete on local data

and

 Grouping (tree style like previous feedback).

Any idea how many jqgrid features you will enable ?

Regards
Andrew
Comment by Andrew Tierney [http://www.castlesoft.com.au] on February 22, 13:51

jqGrid in Relax 

Andrew,

  yes, I saw jgGrid has a lot of nice features.  I'm a 
little skeptical about in-grid editing. But 
master/details and tree style and many other features 
are very nice.

No immediate plans... but might do it later. If you are 
itnerested, more than willing to do some joint work.
Comment by Marco Cantu [http://www.marcocantu.com] on February 22, 23:16

jqGrid in Relax 

Hi Marco,

Agree. In-grid is not crash hot.

Click/popup dialog would be nicer.
And is available via the edit:true in the navGrid
below. (Currently doesn't work either, probably due to
missing search, haven't checked this yet.)

Happy to join in and send any code I can.

I started to play with searching (which isn't in the
current svn).

I added the following to JQGrid.html

 
jQuery("#grid").jqGrid('navGrid','#gridpager',{del:false,add:false,edit:false},{},{},{},{multipleSearch:true});
 
jQuery("#grid").jqGrid('filterToolbar',{stringResult:
true,searchOnEnter : true});

This enables the toolbar search and the multi-search
in the grid. 

The JSON it produces is as follows has an additional
parameter:

// Single Search:
//
//     
filters={"groupOp":"AND","rules":[{"field":"JOB_CODE","op":"bw","data":"Eng"}]}
//
// Multi Search:
//
//    
'filters={"groupOp":"AND","rules":[{"field":"JOB_CODE","op":"bw","data":"Eng"},{"field":"FIRST_NAME","op":"eq","data":"AAA"}]}'
//

From looking at the demo it would appear that I need
to do a couple of things to enable this.


1) Modify the ReadParameters() method:

procedure TRlxjqGrid.ReadParameters( theParams: TStrings)
begin
  FActualPage := StrToInt(theParams.Values['page']);
  FRowLimit := StrToInt(theParams.Values['rows']);
  FSortOrder := theParams.Values['sord'];

// Single Search:
//
//     
filters={"groupOp":"AND","rules":[{"field":"JOB_CODE","op":"bw","data":"Eng"}]}
//
// Multi Search:
//
//    
'filters={"groupOp":"AND","rules":[{"field":"JOB_CODE","op":"bw","data":"Eng"},{"field":"FIRST_NAME","op":"eq","data":"AAA"}]}'
//

  FFilters := theParams.Values['filters'];

  if (theParams.Values['sidx'] = '') then
    FSortColIndex := '1'
  else
    FSortColIndex := theParams.Values['sidx'];
  FStartRow := (FRowLimit * FActualPage) - FRowLimit;
end;

2) Json -> Query string for the new filter param

3) Modify CreateFromTable to use the Filter/Query if
defined.

Should I continue hacking along ? Or will you be
adding the 'filters' parameter in a future build ?

Regards
Andrew
Comment by Andrew Tierney [http://www.castlesoft.com.au] on February 23, 05:07


Post Your Comment

Click here for posting your feedback to this blog.

There are currently 0 pending (unapproved) messages.