PDA

View Full Version : Print a list of values in one cell



Tremal
8 May 2013, 4:11 AM
Hi,

I have a little problem. A JSON response has the next:

[{"name":"Foo",
"list":[{"name":"Boo","id":85}]
}]

And I want to load one grid panel. One column will have the name (works correctly) but the second column prints only [Object].

how I must configura my JSON Object to print only the name field of the list?

Thanks

Mr.Solomon
8 May 2013, 9:37 PM
I think you need a render function in your column definition


header:'colname'
/*...*/
dataIndex:'',//according to your json field
render:function(v){
return v.name
}

Tremal
9 May 2013, 6:02 AM
Hi Mr. Solomon

Thanks about your suggestion. I had have to modify some details:



header:'colname'
/*...*/
dataIndex:'',//according to your json field
renderer:function(v, metaData, record, row, col, store, gridView){
return v[row].name
}


The problem is that prints only one element from the list.

For example, this arrives to the page:

[{"name":"Foo",
"list":[{"name":"Boo","id":85},{"name":"Buu","id":86}]
}]

Tremal
9 May 2013, 6:10 AM
Hi! I'm solved:


renderer : function(v)
{
var result = "";
for (var i=0;i<v.length;i++)
{
result = result + " " + v[i].name }
return result; }

Thanks for your help Solomon