0 Replies Latest reply on Oct 7, 2008 5:23 AM by n3p3nth3

    How could I initialize a CFC with data before binding a grid to it?

    n3p3nth3 Level 1
      Hi there,

      I am refactoring some very old ColdFusion code (ColdFusion 5, not done by me), and I'm considering replacing a huge and complex HTML table with a CFGrid.

      This HTML table is in an INCLUDE file and called from two places, each time it gets a CFQuery with the same name and columns, so the HTML table loop over it, but the (very complex) Queries are built differently.

      It would be a major hassle to "open up" the original queries and build them into the CFC that should supply the data for my CFGrid, so my idea is to wrap the original query into a QoQ, and use the QoQ to display and maybe filter the CFGrid.

      But my problem is, the CFC that I use to bind to the CFGrid has to somehow get the original CFQuery to base the QOQ upon, and I haven't found any way to pass the CFQuery to it! I tried to pass the CFQuery itself in the bind expression as:
      <cfgrid format="html" name="gridTravel" pagesize=25
      sort=true autoWidth=false
      colheaderbold="false" colheaderfont="Franklin Gothic Medium" colheaderfontsize="16"
      selectcolor="##b8ccfa" selectOnLoad=false
      font="Arial" fontsize="12"
      "cfc:travel.getTravelList({cfgridpage},{cfgridpagesize}, {cfgridsortcolumn},{cfgridsortdirection},#TravelQuery# )">

      And I also tried to first initialize the CFC with the CFQuery before the binding:
      travelCfc = createObject("component", "travel");
      travelCfc.travelListBase = TravelSel;

      But nothing works.

      My question, does the binding of CFGrid to a CFC only works in a "static" way (in Java term)?! In that case, the initialization method would clearly never work properly, is it then possible to pass the CFQuery in the Bind at all?

      Given my requirement, what would be the best way of achieving what I'm doing?

      Any suggestion will be appreciated, and many thanks in advance.