PDA

View Full Version : How can i get the dom?



szxiaoyin
26 Apr 2010, 5:13 PM
hi ,Everyone!
I create a tabpanel with two tabs.
in the second tab,i add a combobox with id='cmbCustomer_S'
when i show the window with tabpanel,the first tab is actived,
then i want set the combobox valuefield and displayfield. like this:

Ext.getCmp('cmbCustomer_S').setValue("dis");
Ext.getDom('cmbCustomer_S').value="demo"

but, Ext.getDom('cmbCustomer_S') is null , and Ext.getDom('cmbCustomer_S').value="demo" get a error

why?

darthwes
26 Apr 2010, 5:41 PM
Yuck. setValue is the only call you should need unless your doing some dynamic loading onto the combobox without a store (silly). That's the selected value of the combo box. The combobox is an Ext.Component, you would use Ext.getCmp to look it up. setValue may trick you a bit, as the value of the field when you submit it may be different than the displayed value. You should use some indirection to find the value you're looking for in the combobox's store.

getDom, get().dom are getting the dom elements, not Ext components. They don't generally have a value property, especially not when you evaluate a null.value, which of course blows up. selectedIndex might be a worthwhile property to investigate if you actually needed to look at the dom elements. But as I said, .setValue should be sufficient. Perhaps you just need to do an indirection off the store (store.find) on a value to find the index number and then setValue the index and not the display value?

szxiaoyin
26 Apr 2010, 6:56 PM
combobox's store.??????

i can't understand!

show my code:


about combobox:

columnFirst = [
{
fieldLabel: '<span style="color: red;" >*</span>Customer',
xtype: 'combo',
id: 'cmbCustomer_S',
store: storeCustomerInfo,
valueField: 'KeyId',
displayField: 'CompanySChinaName',
allowBlank: false,
blankText: "not null",
forceSelection: true,
triggerAction: 'all',
pageSize: 20,
listWidth: 400,
typeAheadDelay: 10000,
tpl: new Ext.XTemplate(
'<div class="x-grid3"><div><table>',
'<thead class="x-grid3-header"><tr class="x-grid3-hd-row">',
'<td class="x-grid3-hd x-grid3-cell x-grid3-hd-inner" style="width: 80px;color: blue;">A</td>',
'<td class="x-grid3-hd x-grid3-cell x-grid3-hd-inner" style="width: 80px;color: blue;">B</td>',
'<td class="x-grid3-hd x-grid3-cell x-grid3-hd-inner" style="width: 80px;color: blue;">C</td>',
'<td class="x-grid3-hd x-grid3-cell x-grid3-hd-inner" style="width: 80px;color: blue;">D</td>',
'</tr></thead><tbody>',
'<tpl for=".">',
'<tr class="x-combo-list-item">',
'<td class="x-grid3-col x-grid3-cell"><div class="x-grid3-cell-inner" style="font-size:12px;">{CompanySChinaName}</div></td>',
'<td class="x-grid3-col x-grid3-cell"><div class="x-grid3-cell-inner" style="font-size:12px;">{CompanyChinaAddress}</div></td>',
'<td class="x-grid3-col x-grid3-cell"><div class="x-grid3-cell-inner" style="font-size:12px;">{LinkPeople}</div></td>',
'<td class="x-grid3-col x-grid3-cell"><div class="x-grid3-cell-inner" style="font-size:12px;">{CompanyTelephone}</div></td>',
'</tr>', '</tpl>', '</tbody></table></div></div>')
}


my combobox's store is dynamic loading,how can i find the index number and then setValue the index?????

i explain again :
when the first tab is actived,i can't getDom ,but,when the second tab is actived ,i get it!!!!

why??

you'd best write demo code

darthwes
26 Apr 2010, 8:27 PM
ok

CrazyEnigma
26 Apr 2010, 9:45 PM
Please read me first STICKY about posting. This will help you out a lot. Post your code in code tags is the bare minimum.

My combo box is dynamically loading too, but I have managed to set the value using the above method mentioned. However, if the combo has not been loaded first, you will need to use the "load" listener on the store, within it find the form, find the combo box and set the value using setValue.

Now when you say you have a dynamic store, does this mean that the existing value that you set may not be valid.

szxiaoyin
26 Apr 2010, 10:44 PM
thanks,
i think this is a bug.
the question not about quomodo but about bug

Condor
26 Apr 2010, 11:48 PM
1. Components on hidden tabs are only rendered when the tab is activated (or if you configure the tabpanel with deferredRender:false).
2. If the combobox store is loaded you only have to call combobox.setValue(value) to set both the value and the display text. If your store is not yet loaded I recommend using the override from this feature request (http://www.extjs.com/forum/showthread.php?75751-OPEN-42-ComboBox-s-setValue-call-with-a-remotely-loaded-Store&p=400274#post400274).

szxiaoyin
29 Apr 2010, 6:53 PM
Thanks,Condor...