PDA

View Full Version : HTML elements inside a Grid - lose their id



maya
18 Jun 2007, 2:44 AM
Hi,

I have some HTML elements inside Grid cells with a unique id.
After the grid creation, I try to find those elements pragmatically, using Ext.get('their id') - but this call returns "null".

How can I retrieve elements inside grid cells?

Thanks,
Maya

Animal
18 Jun 2007, 3:02 AM
Are you sending data from the server with ids in? Using a custom column renderer?

What are you trying to do? Change the styling on the fly, or access the underlying data?

maya
18 Jun 2007, 3:37 AM
I am trying to change the styling on the fly. I just made a test - to change the style when clicking on a button. In this case I can retrieve the elements by their id.

My conclusion is - that I tried to find the elements before the grid completed creating all its cells. How can I know when the grid's creation is terminated? my code is already after the "grid.render();" line.

Thanks

Animal
18 Jun 2007, 3:58 AM
render() ends up calling .delay so there's no guarantee that it will have finished on return.

If you want to change styling upon first render, then use a custom renderer for a column.

If you want to change it on the fly based on events, use GridView methods (Sorry, you'll have to read the source for now to find them) to access rows and cells.

maya
18 Jun 2007, 4:55 AM
Actually, what I am trying to do is this:

I had form elements in a table in a former version of my application.
In my new app. version I try to present them in a grid (I am not using the GridEditor since some of my form elements are multiple selection lists).

While trying to present form elements in a grid, I have a focus problem, e.g. when clicking on a selection list it is closed immediately (even if I remove the grid's event handlers).

Therefore, I wanted to apply Ext form element characteristics to my form element after the grid is rendered - hoping that they will have no focus issues. For example, changing a selection list by writing the following code after the grid is rendered:
<code>
Ext.onReady(function(){
var converted = new Ext.form.ComboBox({
typeAhead: true,
triggerAction: "all",
transform: "form_element_name",
width:135,
forceSelection:true
});
});
</code>
But - this code failed since I can't schedule it after the grid completed its creation.

I also can't define a rendered for this column, because each cell should be rendered differently - using its selection list id (in transform: "form_element_name").

Any suggestions?

maya
18 Jun 2007, 6:38 AM
Is there any way I can know when the Grid finished rendering?