iterator and datatable to auto-reflect payload data structure

2 views
Skip to first unread message

focusfriend

unread,
Feb 27, 2008, 11:32:42 AM2/27/08
to Appcelerator Platform SDK
Is it possible for an iterator and datatable to dynamically reflect
the payload data structure? E.g. show all the values without knowing
upfront the field names and number of fields that are coming in.

amro

unread,
Feb 27, 2008, 11:44:27 AM2/27/08
to Appcelerator Platform SDK
So you want it to literally just dump the data into a div as plain
text without formatting? I'm not sure I understand.

Mark Luffel

unread,
Feb 27, 2008, 11:53:22 AM2/27/08
to appcelerator...@googlegroups.com
I'd suggest doing this data transformation outside the (visible) interface.

<app:script>
$MQL("r:message_to_transform", function(msgtype, data) {
  $MQ("r:transformed_message", $H(data.someproperty).map(Prototype.K));
});
</app:script>

the .map(Prototype.K) is just a way of saying "iterate over this hash, get key-value pairs, and save those in a lsit without changing them"

and then use the transformed message like this:

<app:iterator on="r:transformed_message then execute">
 #{key}: #{value}
</app:iterator>

--Mark

focusfriend

unread,
Feb 27, 2008, 1:52:03 PM2/27/08
to Appcelerator Platform SDK
I want to display a grid, but the number of columns can vary within
the different payloads.

-Ivo

On 27 feb, 17:53, "Mark Luffel" <markluf...@gmail.com> wrote:
> I'd suggest doing this data transformation outside the (visible) interface.
>
> <app:script>
> $MQL("r:message_to_transform", function(msgtype, data) {
> $MQ("r:transformed_message", $H(
> data.someproperty).map(Prototype.K));});
>
> </app:script>
>
> the .map(Prototype.K) is just a way of saying "iterate over this hash, get
> key-value pairs, and save those in a lsit without changing them"
>
> and then use the transformed message like this:
>
> <app:iterator on="r:transformed_message then execute">
>  #{key}: #{value}
> </app:iterator>
>
> --Mark
>

TrumpetX

unread,
Feb 27, 2008, 2:41:41 PM2/27/08
to Appcelerator Platform SDK
I've used a simple PHP bit of code to load the $MQ payload - it's not
fancy, but it works.

<app:script style="display:none;">
$MQ('l:load.datatable',{'rows':[
<? $classObject->spit_out_$mq_rows(); ?>
]});
</app:script>

amro

unread,
Feb 27, 2008, 2:52:32 PM2/27/08
to Appcelerator Platform SDK
One way to do it would be to normalize the length of the rows to the
longest length. You could then next iterators to handle the 2d array.

amro

unread,
Feb 27, 2008, 2:53:10 PM2/27/08
to Appcelerator Platform SDK
Actually, you should just be able to nest two iterators without the
normalization bit.
Reply all
Reply to author
Forward
0 new messages