Can you programatically set a row to be highlighted in a CFGRID? I want to have the first row selected every time the form is loaded so as to populate some other fields I have in the form which are bound to the grid? Anyone got any code that does this???
This will do it. --Holly <cfscript> title = "Binding an image to a cfgrid with thumbnail"; properties = queryNew("id,name"); queryAddRow(properties); querySetCell(properties,'id','1'); querySetCell(properties,'name','Tom'); queryAddRow(properties); querySetCell(properties,'id','2'); querySetCell(properties,'name','Dick'); queryAddRow(properties); querySetCell(properties,'id','3'); querySetCell(properties,'name','Harry'); queryAddRow(properties); querySetCell(properties,'id','4'); querySetCell(properties,'name','Sally'); </cfscript> <cfsavecontent variable="onLoad"> grdProps.setFocus(); grdProps.setSelectedIndex(0); </cfsavecontent> <cfsavecontent variable="binding"> {(trigger.text != '') ? trigger.dispatchEvent({type:'change'}) : 'init'} </cfsavecontent> <cfform name="mainform" format="flash" method="post" width="400" onchange="#onLoad#" bind="#binding#"> <cfformgroup type="panel"> <cfformgroup type="horizontal"> <cfformgroup type="vbox"> <cfgrid format="flash" query="properties" name="grdProps" width="240" rowheaders="no"> <cfgridcolumn name="name" header="Name"> </cfgrid> <cfinput type="text" visible="false" height='0' width="0" name="trigger" value="init" onchange="#onLoad#" bind="#binding#"> </cfformgroup> </cfformgroup> </cfformgroup> </cfform>
This works, thx !!! But can you give us a few words of what is the invisible textbox and the second cfsavecontent-tag exactly does, please?
Don't see what you're looking for? Try a search.
|