The first thing i did was :

onSuccess: function(json) {
    var list = json.d;
    var table = new Element('table', {'width':'100%'});
    list.each(function(item) {
        var tr = new Element('tr');
        var td = new Element('td', { 'text': list.Id }).inject(tr);
        var td = new Element('td', { 'text': list.RoleName }).inject
(tr);
        var td = new Element('td', { 'text': list.AddDate }).inject
(tr);
        var td = new Element('td', { 'text': list.Active }).inject
(tr);
        tr.inject(table);
    }.bind(this))
    table.inject($(this.options.container));
}.bind(this)

And this works fine, but I need to be able to do it without having to
write the Id, RoleName, AddDate and Active ?

On 30 Dec., 09:23, Sanford Whiteman <[email protected]>
wrote:
> > I'm making a class to create a table and fill that table with data
> > from JSON. But I can't find a way to loop throug my JSON object
> > without hardcoding the key/value pair.
>
> each().
>
> Or  getKeys()  if  you want to get a list of the keys and get() by key
> after that.
>
> --Sandy

Reply via email to