jsselect to loop over object properties

37 views
Skip to first unread message

Martin Minka

unread,
Dec 3, 2012, 5:31:42 PM12/3/12
to google-j...@googlegroups.com

  1. is there a chance that it would be implemented in near future ?
  2. is there any objection against this functionality ?
thank you,
Martin

Steffen Meschkat

unread,
Dec 3, 2012, 6:47:06 PM12/3/12
to google-j...@googlegroups.com
You can very easily do this yourself:

JsEvalContext.setGlobal('keys', function(o) {
  var ret = [];
  for (var k in o) {
    ret.push(k);
  }
  // optionally sort alphabetically ...
  return ret;
});

...

<option jsselect="keys(o)" jsvalues="value:$this" jscontent="o[$this]">

...

So far,
mesch.

Martin Minka

unread,
Dec 4, 2012, 3:49:00 PM12/4/12
to google-j...@googlegroups.com
maybe this will be useful to somebody (had to use $top in jsvars and jseval):

        <tr class="item-row" jsselect="keys(o)" jsvars="v:$top.o[$this]" jseval="console.dir($top.o[$this])">
            <td jscontent="$this" >here will be the key</td>
            <td jscontent="v" >here will be the value</td>
            <td jscontent="$top.o[$this]" >more verbose access to value, jsvars is not needed for this to work</td>
        </tr>

Dňa utorok, 4. decembra 2012 0:47:06 UTC+1 mesch napísal(-a):

Martin Minka

unread,
Dec 3, 2012, 6:52:36 PM12/3/12
to google-j...@googlegroups.com
Thank you for quick answer. This is sufficient for my needs.

Sincerely,
Martin

2012/12/4 Steffen Meschkat <steffen....@gmail.com>
Reply all
Reply to author
Forward
0 new messages