PDA

View Full Version : ComboBox Values



finco
5 Apr 2007, 8:17 PM
I'm just started to play with extjs. I've put my code below and have three questions:
1. How do I get to the valueField of the combobox. I only seem to get the displayValue.
2. In the function DoSearch, the commented line does not work. I get an undefined error. Can someone please tell me what I'm doing wrong.
3. How do I add a submit button to the dorm?

Thanks in advance for your help.



<html>
<head>
<title>Test</title>
<link rel="stylesheet" type="text/css" href="../../yui/yui-ext/resources/css/ext-all.css"/>
<!-- LIBS -->
<script type="text/javascript" src="../../yui/yui-ext/yui-utilities.js"></script>
<script type="text/javascript" src="../../yui/yui-ext/ext-yui-adapter.js"></script>
<script type="text/javascript" src="../../yui/yui-ext/ext-all.js"></script>
<script language="javascript" src="ftt.js"></script>
<!-- ENDLIBS -->

<link type="text/css" rel="stylesheet" href="proximity.css">


<script type="text/javascript">
// simple array store
Ext.onReady(function(){
// simple array store
var store = new Ext.data.SimpleStore({
fields: ['fttcode', 'fttdesc'],
data : Ext.data.ftt // from states.js
});
var combo = new Ext.form.ComboBox({
store: store,
displayField:'fttdesc',
valueField:'fttcode',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Select a category...',
selectOnFocus:true
});
combo.applyTo('ftt');

var btnSearch = new Ext.Button('btn1',
{text: 'Search'
});
Ext.get('btn1').on('click', function(){
DoSearch();
});

});

function DoSearch() {
// var ftt = Ext.get("ftt").value
var ftt=document.getElementById("ftt").value;
alert(ftt);
}
</script>
</head>
<body>
<form method="post" id="frmParameters" name="frmParameters">
<input type="text" id="ftt" name="ftt" size="35">
<div id="btn1"></div>
</form>

</body>
</html>

kjordan
5 Apr 2007, 8:31 PM
1. Use combo.getValue();
2. It would be Ext.get('ftt').dom.value, but use the getValue function in Combo.js
3. You might look into using Jack's Form class (although he says it's still rough and might change in the future). You can then add a button which is either a HTML submit button or an Ext button that calls myFormObj.submit(); where myFormObj is an Ext Form wrapper object.

finco
6 Apr 2007, 2:34 AM
Thanks very much. Worked like a charm. I'll have to try the form class but in the meantime this gives me the ability to pass the values as needed.

Wolfgang
19 Apr 2007, 2:23 PM
Thanks very much. Worked like a charm. I'll have to try the form class but in the meantime this gives me the ability to pass the values as needed.

When you want to start with the form class, here a basic example including PHP backend:
http://extjs.com/forum/showthread.php?p=23343