我们正在将CF Server 9升级到最新的CF2018。我正面临下拉选择值和cfgrid绑定之间的绑定问题。
在cfgrid上方有一个下拉菜单,该下拉菜单最初设置为空,并列出了查询的值,而在下面的网格是将下拉选择值绑定到所获取查询的网格。
首先,由于选择了空,因此将不会获取记录,并且网格将为空。绑定URL的格式也正确。
但是接下来,当我将下拉列表选择为新值时,URL便以这种方式形成。
如您所见,SrcID两次被追加,第一次为空,然后添加所选值。我在下一页将其作为逗号分隔的值接收,这是不正确的。 查询参数将作为单独的参数添加,而不是取代旧的参数。
SrcID参数在顶部定义,下一个是下拉列表,直接在底部是cfgrid(在绑定中使用该参数)。 预先感谢
这是下面的示例代码
<cfajaximport tags="cfform, cfinput-datefield, cftooltip, cfwindow, cfgrid, cfmessagebox">
<script type="text/javascript" language="javascript">
function doRefresh(form){
cSrcID = form.SrcID.options[form.SrcID.selectedIndex].value;
console.log('me'+cSrcID+'u');
cSortFld = '';
form.newSrcID.value = cSrcID;
}
// get client area of the browser
var cliWt = getClientWt(); // client width
var cliHt = getClientHt(); // client height
// set grid dimensions scrWidth, scrHeidht
var gWt = 34; // right margin
var gHt = 180; // top margin
var minWt = 500; // min width of the table
var minHt = 280; // min height of the table
var scrWidth = cliWt - gWt;
var scrHeight = cliHt - gHt;
if (scrWidth < minWt) scrWidth = minWt;
if (scrHeight < minHt) scrHeight = minHt;
// set winEdit popup window dimensions
var popwinWt = 1150;
var popwinHt = 680;
var bResizePopup = 0;
if (popwinWt > cliWt) {
bResizePopup = 1;
popwinWt = cliWt - 10;
}
if (popwinHt > cliHt) {
bResizePopup = 1;
popwinHt = cliHt - 10;
}
// set winEdit2 popup window dimensions
var popwinWt2 = 900;
var popwinHt2 = 510;
var bResizePopup2 = 0;
if (popwinWt2 > cliWt) {
bResizePopup2 = 1;
popwinWt2 = cliWt - 10;
}
if (popwinHt2 > cliHt) {
bResizePopup2 = 1;
popwinHt2 = cliHt - 10;
}
// set winEdit3 popup window dimensions
var popwinWt3 = 800;
var popwinHt3 = 550;
var bResizePopup3 = 0;
if (popwinWt3 > cliWt) {
bResizePopup3 = 1;
popwinWt3 = cliWt - 10;
}
if (popwinHt3 > cliHt) {
bResizePopup3 = 1;
popwinHt3 = cliHt - 10;
}
</script>
<cfset maxRowCnt = 174>
<!--- Set Grid default params --->
<cfparam name="page" default="1">
<cfparam name="pageSize" default="#maxRowCnt#">
<cfparam name="cfgridsortcolumn" default="">
<cfparam name="cfgridsortdirection" default="">
<cfform name="mainForm">
<cfoutput>
<br /><cfselect name="SrcID" title="Select a Source" style="width:200px;" onchange="doRefresh(this.form)">
<option value="">Select a Data Source</option>
<option value="Test">Test</option>
</cfselect>
<input type="hidden" name="newSrcID" value="">
<input type="hidden" name="flt_nm" value="" />
<input type="hidden" name="flt_iv" value="" />
<input type="hidden" name="flt_ct" value="" />
<input type="hidden" name="flt_sc" value="" />
<input type="hidden" name="flt_in" value="" />
</cfoutput>
<!--- Main Grid title="List of Records" --->
<cfgrid format="html" name="mainGrid" sort="yes" style="border:1px solid ##002D96;" visible="no" pagesize="#maxRowCnt#" maxrows="#maxRowCnt#" vspace="20"
striperows="yes" striperowcolor="#gcGray#" bgcolor="#gcRowWhite#" colheaderbold="yes" colheadertextcolor="##464646" width="scrWidth" height="scrHeight"
selectcolor="##FFCC99" selectmode="edit" selectonload="false" picturebar="yes" gridlines="yes" autowidth="yes"
bind="url:dummy.cfm?DbFunc=getRecords&SrcID={SrcID}&newSrcID={newSrcID}&flt_nm={flt_nm}&flt_iv={flt_iv}&flt_ct={flt_ct}&flt_sc={flt_sc}&flt_in={flt_in}&page={cfgridpage}&pageSize={cfgridpagesize}&sortCol={cfgridsortcolumn}&sortDir={cfgridsortdirection}"
onchange="url:dummy.cfm?DbFunc=doNothing&action={cfgridaction}&row={cfgridrow}&changed={cfgridchanged}"
font="arial" fontsize="14px" colheaderfont="arial" colheaderfontsize="14px" textcolor="##464646">
<cfgridcolumn name="si_id" header="ID" display="yes" select="no" width="45"/> <!--- FDB-164 --->
</cfgrid>
</cfform>
在dummy.cfm上
根据所选的Src ID返回JSON格式的查询数据