7 Replies Latest reply on May 13, 2011 5:31 AM by ecommerce web solutions

    CFGRID binding CFSELECT and Cookie


      I an just dipping my toes into the CF8 AJAX tags and am having a blast. I have run into an issue that I need assistance on though. If this has been already answered by another post, I cannot find it. So if there is one, please point me in the right direction.


      Here is my issue...


      I have an order form and am using a CFGRID to show order history. [Note:this is not a typical ecommerce order form. It is a way for my customer, who provides products to non-profits a way they can place their orders online, but no cc processing]. Anyway, I have a cfselect that is a list of the organizations that use this site. They select their organization, which populates the db upon submission for ease of processing orders, but also sets a cookie so the customer does not have to redo the cfselect everytime since they are inputting lots of orders at once.


      So, I have a CFGRID so they can see all of their orders that have been placed to date. I used the bind attribute to bind my cfgrid to the cfselect, which in turn pulls query data from a cfc. The problem I am running into is that when the page loads and the cfselect gets the proper value selected based upon the cookie, the cfgrid does not seem to pick that up and populate with the correct query information. It only populates when the cfselect is changed. I am thinking that this has to do with server side versus client side processing, but have not been able to figure out a way around the issue.


      Any help is appreciated.


      Here is my code...



      <cfcomponent displayname="orders" hint="CFC for retrieving data from orders db">
      <!---This function retrieves all orders from the db based upon where parameter (organization)--->
      <cffunction name="getOrders" access="remote" returntype="struct" hint="returns all orders for a specific organization/customer">
              <cfargument name="page" required="true" />
              <cfargument name="pageSize" required="true" />
              <cfargument name="gridsortcolumn" required="true" />
              <cfargument name="gridsortdirection" required="true" />
              <cfargument name="organization" type="string" required="true" />
              <cfif gridsortcolumn EQ "DATEORDERED">
               <cfset gridsortcolumn = "ORDERSIGNUPDATE">
              <cfquery name="rsOrgOrders" datasource="BadgerWreathOrders">
                  FROM Orders
                  WHERE ORDERORGANIZATION = '#organization#'
                  <cfif gridsortcolumn NEQ ''>
                  ORDER BY #gridsortcolumn# #gridsortdirection#
        <cfreturn queryconvertforgrid(rsOrgOrders,page,pageSize)>



          <cfgrid name="orderGrid" bindonload="yes" colheaderbold="Yes" font="Verdana, Geneva, sans-serif" fontsize="9px" label="true" striperows="yes" striperowcolor="##CCCCCC" selectcolor="##00CC66" rowHeaders="No" format="html" bind="cfc:cfc.orders.getOrders({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridso rtdirection},{organization})" pageSize="10" preservepageonsort="true" selectmode="single" selectonload="false" bgcolor="##F4FFE4" colheaderfontsize="9px">
              <!--- cfgridcolumn tags arrange the table and control the display. --->
              <!--- Hide the primary key, required for update --->
              <cfgridcolumn name="ORDERID" display="No" />
              <cfgridcolumn name="ORDERFIRSTNAME" header="First Name" Select="No" width="65" />
              <cfgridcolumn name="ORDERLASTNAME" header="Last Name" Select="No" width="65" />
              <cfgridcolumn name="ORDERADDRESS1" header="Address 1" width="105" />
              <cfgridcolumn name="ORDERADDRESS2" header="Address 2" width="60" />
              <cfgridcolumn name="ORDERCITY" header="City" width="55" />
              <cfgridcolumn name="ORDERSTATE" header="State" width="35" />
              <cfgridcolumn name="ORDERZIP" header="Zip" width="30" />
              <cfgridcolumn name="DATEORDERED" header="Order Date" width="65" />


                    <cfselect name="organization" id="organization" onBlur="WA_setCookie(WA_CookieObj,'badgerorderorg',document.ecart_checkout_form.organizat ion.value,true,0,30)">
                    <option value="none" selected="selected">Please select your organization</option>             
                    <option value="Cornerstone Christian School">Cornerstone Christian School</option>             
                    <option value="Faith Christian Academy">Faith Christian Academy</option>             
                    <option value="Knute Rockne Memorial Kiwanis Club of Granger">Knute Rockne Memorial Kiwanis Club of Granger</option>             

      Thanks in advance