View Full Version : Selecting an attribute from a HTMLElement

17 Nov 2009, 6:15 AM

I am using a Ext.DataView to view my Data. If I select an entry the event
"selectionchange" is fired where I get the selected nodes. These nodes are
HTMLElements, for example in this format:

<td style="visibility:hidden" index_id="5">5</td>

Iīve checked DomQuery but could not find a solution how to limit the queries
to that specific HTMLElement.

How can I get the value of the attribute "index_id"? Could someone please give
me an example?

Many thanks and best regards

17 Nov 2009, 6:20 AM
Do you really need to store the index_id in the HTML? Can't you retrieve it from the dataview store instead?

17 Nov 2009, 6:31 AM
No, there is no need to retrieve it from the DOM. The data is also stored in the JsonStore,
but I donīt know how to I can select from the DataStore with the selections-HTMLElement as reference.

17 Nov 2009, 6:54 AM
What I did now (and itīs working):

var selectedRow = dv.getSelectedIndexes()[0];
var selectedIndexId = store.getAt(selectedRow).id);

I am selecting (single select) the first element (number) of the Ext.DataView.
Then I select it from the store by using this number an get the id.

Is this a common way to do it?

17 Nov 2009, 7:59 AM
Yes, that would work. Another option would be using the viewIndex property, e.g.

dataview.on('selectionchange', function(view, selections){
var record = selections.length ? view.store.getAt(selections[0].viewIndex) : null;