PDA

View Full Version : How can I assign a custom property to every element of an XTemplate



Fire-Dragon-DoL
17 Dec 2011, 10:46 AM
I would like to open a custom window based on a property name returned by a Json object. This json object builts the items of a View, and I would like to attach a custom property to each item of the XTemplate which will contain the value of the json object.

After, it will be possible to read this property in the itemdblclick event of the View.

How can I manage to do such a thing?

skirtle
17 Dec 2011, 6:29 PM
Perhaps I've misunderstood the question but couldn't you just grab the record in the itemdblclick handler and use that to locate the property you're interested in? I don't see a good reason to store this information on the element.

Fire-Dragon-DoL
17 Dec 2011, 7:23 PM
Mh well the problem is that I'm creating a view from a JSON store, one of the properties from that json should be attached in some way to an item that will be templated with xtemplate, because there isn't a good place in html where it fits (it's a name of the extjs window class I should open). So yes I can grab the property when I'm in itemdblclick, but this property it's not a default one but something I want to create on the item.

I don't even know if this is possible, actually I'm using a workaround accessing the store with the index obtained from itemdblclick params and it's working well.

skirtle
17 Dec 2011, 8:34 PM
You don't need to use the index. The second argument passed to the itemdblclick handler is the record.

I'm not sure why you see it as a workaround. Getting data directly out of the store/record is how you're supposed to do it. Trying to bodge it into the HTML would be a workaround...

Fire-Dragon-DoL
17 Dec 2011, 8:55 PM
Oh, ok thank you, so it's working fine. Thanks a lot!