You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

CF9升级至CF2018时cfgrid与下拉框绑定参数重复问题

Fix for Duplicate SrcID Parameter in CFGrid After Upgrading to ColdFusion 2018

I’ve run into similar binding quirks when upgrading from older ColdFusion versions to 2018, so let’s break down what’s happening and how to fix it:

Root Cause

Your current cfgrid bind URL includes both SrcID={SrcID} and newSrcID={newSrcID}. ColdFusion 2018’s AJAX binding engine handles form element references more strictly than CF9. When your doRefresh function updates the hidden newSrcID field, the grid’s bind ends up picking up both the original SrcID select value and the hidden field’s value—leading to duplicate SrcID parameters in the request. Alternatively, the engine might be appending the old empty value of SrcID instead of overwriting it when the dropdown selection changes, resulting in the comma-separated invalid value your backend receives.

Step-by-Step Fix

Option 1: Simplify the Bind to Use the Hidden Field

Since you’re already copying the SrcID value to newSrcID in your JS function, you can remove the redundant SrcID={SrcID} parameter from the bind URL and only use the updated hidden field value:

<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&amp;SrcID={newSrcID}&amp;flt_nm={flt_nm}&amp;flt_iv={flt_iv}&amp;flt_ct={flt_ct}&amp;flt_sc={flt_sc}&amp;flt_in={flt_in}&amp;page={cfgridpage}&amp;pageSize={cfgridpagesize}&amp;sortCol={cfgridsortcolumn}&amp;sortDir={cfgridsortdirection}" onchange="url:dummy.cfm?DbFunc=doNothing&amp;action={cfgridaction}&amp;row={cfgridrow}&amp;changed={cfgridchanged}" font="arial" fontsize="14px" colheaderfont="arial" colheaderfontsize="14px" textcolor="##464646">

Option 2: Remove the Hidden Field Entirely

If you don’t need the newSrcID hidden field, you can simplify further by using the dropdown’s value directly in the bind, and clean up the JS function:

  1. Update the JavaScript doRefresh function to remove the hidden field update:
    function doRefresh(form){
      cSrcID = form.SrcID.options[form.SrcID.selectedIndex].value;
      console.log('me'+cSrcID+'u');
      cSortFld = '';
      // Delete the line that updates newSrcID
    }
    
  2. Remove the hidden newSrcID input from your form:
    <!--- Remove this line --->
    <input type="hidden" name="newSrcID" value="">
    
  3. Update the cfgrid bind to use only SrcID={SrcID}:
    bind="url:dummy.cfm?DbFunc=getRecords&amp;SrcID={SrcID}&amp;flt_nm={flt_nm}&amp;flt_iv={flt_iv}&amp;flt_ct={flt_ct}&amp;flt_sc={flt_sc}&amp;flt_in={flt_in}&amp;page={cfgridpage}&amp;pageSize={cfgridpagesize}&amp;sortCol={cfgridsortcolumn}&amp;sortDir={cfgridsortdirection}"
    

Verify the Fix

After making these changes, use your browser’s developer tools (Network tab) to inspect the AJAX request when you select a dropdown value. You should see only a single SrcID=Test parameter in the URL, with no duplicates or empty values appended.

Why This Works in CF2018

ColdFusion 2018 updated its underlying AJAX framework for cfgrid and related tags, which changed how form element values are resolved in bind expressions. Unlike CF9, it doesn’t automatically ignore redundant parameter references—instead, it includes all resolved values, leading to the duplicate parameters. By simplifying the bind to use only one source for the SrcID parameter, you eliminate this collision.

内容的提问来源于stack exchange,提问作者user9807332

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 09:28:29