PDA

View Full Version : populate ext.form.combobox (ext 2.) from an sql database using coldfusion 9



sarahmfr
25 May 2010, 1:27 PM
Thanks in advance.
How can I populate ext.form.combobox from sql database in coldfusion.
I have component that has a function that returns the query result in array format.
<cfinvoke component="state" method="getstates" returnvariable="statesList">

currently I am providing the list of states manually to the combobox
___________________________________


here is my code
<html>
<head>
<script type="text/javascript">
var gridRender = function()
{
//over
grid = ColdFusion.Grid.getGridObject('disciplineGrid');

//Below code adds the Row Numbering to the grid
cols = grid.getColumnModel();
configA = cols.config;
newcolumn = new Ext.grid.RowNumberer(); //Adds the Row Numbering to the grid
temp = configA.splice(0,0,newcolumn);


//create an ext.combobox
var cmbstate = new Ext.form.ComboBox({
id:"cmbstate",
emptyText:"State",
mode:"local",
width:65,
triggerAction:"all",
displayField:"text",
valueField:"value",
store:new Ext.data.SimpleStore({fields: ["value","text"],data:[['CA','CA'],['CO','CO'],['FL','FL']]})
store:mySimpleStore
});

//Insert blank div on top of the grid.
var tbar=Ext.DomHelper.insertFirst(grid.el,{tag:'div',id:Ext.id()},true);
//Convert inserted div to Ext toolbar
var gtbar = new Ext.Toolbar({
renderTo: tbar,
items: [cmbstate,'-',

{
text:"Reload",
cls:"x-btn-text",
tooltip:"Reload",
handler: function(){ColdFusion.Grid.refresh('disciplineGrid');}
},
]
});



};
</script>
</head>
<body>
<br/><br/>
<cfinvoke component="state" method="getstates" returnvariable="statesList">




<cfgrid format="html" name="disciplineGrid" pagesize="10" selectmode="row"
bind="cfn_Discipline_ALL({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection})">
<cfgridcolumn name="DisciplineID" display="yes" />
<cfgridcolumn name="DisciplineNAME" header="DisciplineNAME" >

</cfgrid>
</cfform>
<cfset ajaxOnLoad("gridRender")>
</body>
</html>