change json reply

45 views
Skip to first unread message

BramNl

unread,
Jan 27, 2012, 1:03:07 PM1/27/12
to Delphi on Rails
procedure TAjaController.getdatax_get(const sTerm: string ; out data:
ISuperObject);
with pool.GetConnection.newContext do
begin

data:= Execute(newSelect('SELECT FIRST 2 SKIP 20.... etc

---------------------------

gives {"data":[{"label":"3Shift","value":"3Shift"},
{"label":"3T","value":"3T"}]}

but I need

[{"label":"3Shift","value":"3Shift"},{"label":"3T","value":"3T"}]

without 'data'



thnx for your help

Henri Gourvest

unread,
Jan 30, 2012, 4:00:17 AM1/30/12
to delphi...@googlegroups.com
You have to create e JSON view to override the default behavior.

unit aja_view;

procedure  TAjaView.getdatax_json(const data: 
ISuperObject);
begin
  data.SaveTo(Response.Content)
end;

BramNl

unread,
Jan 30, 2012, 9:04:38 AM1/30/12
to Delphi on Rails
Thnx Henri, (To bad DOR is not getting the attention I think it
should deserve...)

Inspired by the ajax controller example, I'am trying to create an
jqueryui.autocomplete wich need an String-Array or Object-Array with
label/value/both properties...
I read all the message's and getting started but somehow I think I
still don't understand the basic concept in total... hope you will
bare with me :-)...

procedure TAjaView.getdatax_json(const term:string;data:
ISuperObject);
var s2Search:string;
begin
with pool.GetConnection.newContext do
begin
data:= (Execute(newSelect('SELECT * FROM musicfiles WHERE ARTIST
LIKE "%'+term+'%" AND ARTIST )));
end;
data.SaveTo(Response.Content );
end;

Its now working but I need the term parameter wich is send by
jquery.autocomplete. Its empty?

Henri Gourvest

unread,
Jan 30, 2012, 9:30:29 AM1/30/12
to delphi...@googlegroups.com
Le 30 janvier 2012 15:04, BramNl <bram.va...@gmail.com> a écrit :
Thnx Henri,  (To bad DOR is not getting the attention I think it
should deserve...)

Thank you
 
Its now working but I need the term parameter wich is send by
jquery.autocomplete.  Its empty?

The view should not connect to database, the controller collect datas and send them automatically to the view.
All var/out parametters in the controller will be sent automatically to the view.
So keep you original controller and the view I have written for you.

--
Henri Gourvest

BramNl

unread,
Jan 30, 2012, 10:06:23 AM1/30/12
to Delphi on Rails
Understood, it works great now. Thnx. Very powerfull to use jquery in
combination with DOR

On 30 jan, 15:30, Henri Gourvest <hgourv...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages