Skip navigation
Currently Being Moderated

CFGRID binding CFSELECT and Cookie

Sep 23, 2009 1:51 PM

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...

 

CFC

<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">
        </cfif>
       
        <cfquery name="rsOrgOrders" datasource="BadgerWreathOrders">
            SELECT FORMAT([ORDERSIGNUPDATE],'mm/dd/yy') AS DATEORDERED, ORDERADDRESS1, ORDERADDRESS2, ORDERCITY, ORDERFIRSTNAME, ORDERID, ORDERLASTNAME, ORDERORGANIZATION, ORDERPHONE, ORDERREFERENCEID, ORDERSTATE, ORDERZIP
            FROM Orders
            WHERE ORDERORGANIZATION = '#organization#'
            <cfif gridsortcolumn NEQ ''>
            ORDER BY #gridsortcolumn# #gridsortdirection#
            </cfif>
        </cfquery>
       
  <cfreturn queryconvertforgrid(rsOrgOrders,page,pageSize)>
</cffunction>
</cfcomponent>

 

CFGRID

    <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},{cfgrids ortcolumn},{cfgridsortdirection},{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" />
    </cfgrid>

CFSELECT

              <cfselect name="organization" id="organization" onBlur="WA_setCookie(WA_CookieObj,'badgerorderorg',document.ecart_che ckout_form.organization.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>             
              </cfselect>

Thanks in advance

~Clay

 
Replies
  • Currently Being Moderated
    Feb 28, 2010 3:25 AM   in reply to Clay Hess

    Did you experiment in the cfselect with onChange in place of onBlur?

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 2, 2010 1:16 PM   in reply to Clay Hess

    You could.


     
    |
    Mark as:
  • Currently Being Moderated
    Mar 8, 2011 3:16 AM   in reply to Clay Hess

    Hello, I'm new on here and excited to be part of the group, Really you have shared great resources for everyone.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 19, 2011 7:37 PM   in reply to Clay Hess

    HI Clay,

     

    Just a thought:

     

    If the organization uses a login (I'm assuming that they are), why not set a SESSION variable equal to what you would use in a SQL WHERE clause.  That way, when you take them to the cfgrid, just use their SESSION variable in the cfc query.

     

    Let's say that the organization is Faith Christian.  When they login you set SESSION.ORDERORGANIZATION = 'Faith Christian'. So in your cfc, you would have:

     

    <cfquery name="rsOrgOrders" datasource="BadgerWreathOrders">
                 SELECT FORMAT([ORDERSIGNUPDATE],'mm/dd/yy') AS DATEORDERED,  ORDERADDRESS1, ORDERADDRESS2, ORDERCITY,           ORDERFIRSTNAME, ORDERID,  ORDERLASTNAME, ORDERORGANIZATION, ORDERPHONE, ORDERREFERENCEID,  ORDERSTATE, ORDERZIP
                FROM Orders
                WHERE ORDERORGANIZATION = '#SESSION.ORDERORGANIZATION#'
                <cfif gridsortcolumn NEQ ''>
                ORDER BY #gridsortcolumn# #gridsortdirection#
                </cfif>
            </cfquery>

     

    This would completely eliminate the cfselect and its bind to the cfgrid.  Just thinking on how to make your life a bit easier with a lot less code.

     

    I don't play with cookies much, but you could probably do the same thing with a cooke variable as opposed to a session variable.

     

    <cfwild>

     
    |
    Mark as:
  • Currently Being Moderated
    May 13, 2011 5:31 AM   in reply to Clay Hess

    Hey nice post. Want to get more idea about this.

    http://www.anylinuxwork.com/solutions/e-commerce.html

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points