我们正在将我们的 CF Server 9 升级到最新的 CF 2018。我正面临下拉选择值和 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 格式的查询数据