• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CFGRID binding CFSELECT and Cookie

Explorer ,
Sep 23, 2009 Sep 23, 2009

Copy link to clipboard

Copied

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},{cfgridsortcolumn},{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_checkout_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

Views

4.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 24, 2009 Sep 24, 2009

Copy link to clipboard

Copied

I believe I figured out how to do this. I thought I would post my solution here in case someone else runs into this issue. If there is a better way, let me know..

What I did was utilize a CFIF statement within my CFC to check for the existence of the cookie and change my WHERE statement accordingly. This should then populate the CFGRID with the appropriate data.

            <cfif IsDefined('cookie.BADGERORDERORG') and cookie.BADGERORDERORG NEQ ''>
             WHERE ORDERORGANIZATION = '#cookie.BADGERORDERORG#'
            <cfelse>
             WHERE ORDERORGANIZATION = '#organization#'
            </cfif>

Again, if anyone has any other thoughts, I would be glad to hear them.

Thanks,

~Clay

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 28, 2010 Feb 28, 2010

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 28, 2010 Feb 28, 2010

Copy link to clipboard

Copied

No I did not

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 02, 2010 Mar 02, 2010

Copy link to clipboard

Copied

You could.


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 08, 2011 Mar 08, 2011

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 19, 2011 Mar 19, 2011

Copy link to clipboard

Copied

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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 13, 2011 May 13, 2011

Copy link to clipboard

Copied

LATEST

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

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation