PDA

View Full Version : JSonView and data, how to get them ?



mediastart
11 May 2007, 2:27 AM
Hi all,

I've a question:

How to get all the data sent to the JSonView by the php script that use the JSonView to fill himself ?

By example, my php script returns :



{"images":[{"index":"0","idContainer":"2","s_labelContainer":"Catalogue 2"},{"index":"1","idContainer":"1","s_labelContainer":"Catalogue Bonjour "},{"index":"2","idContainer":"3","s_labelContainer":"Catalogue

Number 3"},]}



With theses informations the template of my JSonView can retrieve all the informations needed.
But I want, later in my application, when a node is selected, retrieve all the informations that concern the selected node (example , idContainer, or labelContainer etc.) . How I can do that ?

Thanks

BernardChhun
11 May 2007, 3:52 AM
The selection event is catched with the JsonView's "selectionchange" event.


JsonView.on("selectionchange", seeRow, this, true);

the seeRow() function will receive 2 parameters : the view itself and the selection array.

You could also use the click event:


JsonView.on("click", clickRow, this, true);

in this case, the clickRow function will receive 4 parameters:
1st: the view itself
2nd: the index that was clicked
3rd: the node's DOM element
4th: An event object

I'd suggest you read this page from the Docs : http://extjs.com/deploy/ext/docs/output/Ext.JsonView.html

With the view and the index, you should be able to figure out how to do what you want.

mediastart
11 May 2007, 4:06 AM
Hi and thanks BernardChhun, but your answer don't help me. I know that, but the node's DOM element don't contains the informations used to build the node and the template, I talk of theses informations :




{"images":[{"index":"0","idContainer":"2","s_labelContainer":"Catalogue 2"},{"index":"1","idContainer":"1","s_labelContainer":"Catalogue Bonjour "},{"index":"2","idContainer":"3","s_labelContainer":"Catalogue

Number 3"},]}


A try to list all of the properties of the node's DOM element but I can't find theses informations.

Thanks for your help :-)

BernardChhun
11 May 2007, 4:27 AM
If you browse through the public methods of the JsonView's docs, you should see a getNodeData(HTMLElement/Array node) function. its description is crystal clear:


getNodeData
public function getNodeData(HTMLElement/Array node)
Returns the JSON object for the specified node(s)
Parameters:
node : HTMLElement/Array
The node or an array of nodes
Returns:
Object/Array
If you pass in an array, you get an array back, otherwise you get the JSON object for the node
This method is defined by JsonView.

my previous post was meant to help you find this function. ;)

mediastart
11 May 2007, 5:20 AM
Thanks ... and sorry, the next time I will search better !!!! I promess !

Thank you