Thank you very much, Oliver, for this detailed reply.

So you change your method according to the type and amount of data.

If there is no clean 1:1 representation between the 4D/A4D data and the
javascript data, individual methods are the way to go.

If I just need some fields from a 4D table cached in JavaScript arrays, as I
have currently, a universal method might be easier to handle.

I've looked into A4D's JSON addRowSet method, which seems to be an ideal
start, as I usually already have generated an appropriate Rowset.

With

$json := a4d.json.new(false)
$json->addRowSet($RowSet)

and within JavaScript

var jason = '<%$json->write(false)%>';
var obj = jQuery.parseJSON(jason);

I quickly get the whole RowSet into an JavaScript object, nice. :-)

What is a bit more difficult, is to deal with this JavaScript object.

Usually I search in one column/field for a value and retrieve the value of a
corresponding column/field .

The problem here is, that the JSON object generated by A4D is row based and
not column based.

So if instead of the current A4D JSON output:

[{"field1":"123"," field2":"1},{" field1":"456"," field2":"2"}]

it would look like:

{"field1":["123","456"],"field2":["1","2"]}

then I could find index of "field1" with value "456" easily with:

var hit = jQuery.inArray("456", obj.field1);

With the row based object there seems to be no other way than looping
through the whole object.

  
@Aparajita: Maybe you could add a parameter to the JSON write method, that
switches between row based and column based output?

Pete


_______________________________________________
Active4D-dev mailing list
[email protected]
http://list.aparajitaworld.com/listinfo/active4d-dev
Archives: http://active4d-nabble.aparajitaworld.com/

Reply via email to