質問

I'm using a dojox.DataGrid in Dojo 1.8, and each of the rows has a button that I attach an onclick handler to. Up to 25 rows, I can easily attach the onclick event to each button this way:

dojo.connect(dojo.byId('button1'), 'onclick', this, 'callback')

However, when there are more than 25 items in the store, the 26th+ rows are not written to the DOM yet, so the line above will fail for the 26th (and oddly attaches the event to the top level DOM element) since dojo.byId('button26') returns null. I know this is because of the paging feature of the DataGrid.

Is there any way to attach event handlers to all of the items in the store itself, or to "future" elements on the DOM that will be there when the DataGrid retrieves the next page? Thanks!

役に立ちましたか?

解決

Since the object does not exist you, you will have to attach to the fetch or store events to know when they will be rendered.

Either use the _onFetchComplete from the grid, or listen to the onComplete from the store.

Here are a couple of related stackoverflow: how to check dojo.datagrid loading completed?

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top