Solved

coldfusion cfform cfgrid column sort

Posted on 2012-03-29
19
586 Views
Last Modified: 2012-04-06
Hi I have the following cfgrid and the column did NOT sort when I click and can't find out why:


<cfform method="get" format="html" id="servicelist" name="servicelist" >
      Client Name:
            <input type="text" id="namesrh" name="namesrh" >

          <cfgrid name="service_list" striperows="yes" format="html" sort="yes"
               selectonload="false"  pagesize="26" height="690"  colheaderbold="yes" selectmode=""browse"
               bind="cfc:cfc.service_list.get_servicelist({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection},{namesrh})"
                              onfocus="" >

          <cfgridcolumn name="ID"              width="40"       header="ID"            headeralign="left">
          <cfgridcolumn name="DATE_SERVICE"        width="75"       header="Service Date"      headeralign="left">
          <cfgridcolumn name="CLIENT_NAME"         width="210"       header="Client Name"       headeralign="left">
          <cfgridcolumn name="PROGRAM"         width="90"      header="Program"       headeralign="left">
          <cfgridcolumn name="LECTURE"          width="210"       header="Lecture"       headeralign="left">
 
           
       </cfgrid>  

   </cfform>

Thank you for helping!!
0
Comment
Question by:jfreeman2010
  • 12
  • 6
19 Comments
 
LVL 15

Expert Comment

by:myselfrandhawa
ID: 37785936
can u tell what error u are getting or field is disabled or what?
0
 

Author Comment

by:jfreeman2010
ID: 37787340
where is no error and when I click on the column hearding, it did not sort the column.
0
 

Author Comment

by:jfreeman2010
ID: 37787445
I am try to make the column sort works in this grid.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 37789966
There is no error and when I click on the column hearding, it did not sort the column.

That does kinda suggest there's an error.  You need to look at the ajax logs or use some sort of javascript debugger.  Assuming it's a dev server (not production) enable ajax debugging in the cf administrator. Then display the ajax logger by appending "?cfdebug" onto the url of your grid page

             ie  http://yoursite.com/path/to/yourGridPage.cfm?cfdebug
               
You could also use Firefox's error console and/or it's Firebug plugin to check for javascript errors.
0
 

Author Comment

by:jfreeman2010
ID: 37796549
I try Firefox's error console and did not see any JavaScript errors.
0
 

Author Comment

by:jfreeman2010
ID: 37796582
I also enable ajax debugging in cf administrator and appending the cfdebug on url and not error shows. ):
0
 
LVL 52

Expert Comment

by:_agx_
ID: 37799088
Does sorting work for any grids?
0
 

Author Comment

by:jfreeman2010
ID: 37803340
Yes for other cfm pages, I used a cfstoredproc to get data, this one did not work used cfc to get data.

I try to use the same cfformand cfgrid param, but still unable to make this one works.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 37804425
Well there's nothing wrong with the grid code above .. so time for a silly question - is your cfc function actually doing a sort ? ;-) Because if you're not getting any errors, that's the only thing I can think of.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:jfreeman2010
ID: 37806872
Thank you for helping!!

I can sort in the cfc function, that its only the first time when display the grid.

if the grid also can sort, then when it needs, user can just click the column heading and sort it the way they want.

And yes, the cfc did sorted the data.

I did tried to comment out the order by in cfc, it did not make a diff for the column heading sort in the grid.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 37807031
I can sort in the cfc function, that its only the first time when display the grid.

Do you mean sorting only works the 1st time the grid is displayed - or do you mean it never works? Also did you try with different browsers?

Any chance you can post a live URL? Because the behavior you're describing is extremely unlikely so I'm not sure what else to suggest if you've eliminated the most likely causes

1) Usually there is a javascript error OR
2) The cfc isn't really sorting the data OR
3) The data IS being sorted, but differently than you think
0
 

Author Comment

by:jfreeman2010
ID: 37807594
I used cfc to get the grid query and it works.  Are you saying what when client click on the column heading, it go back to the cfc query to do the sorting?

I am using IE 8.  I try firefox. - firefox also not working.
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 37809377
I used cfc to get the grid query and it works.  Are you saying what when client click on the column heading, it go back to the cfc query to do the sorting?


With binds, yes.  Your query inside the cfc has to do the sorting. Otherwise, nothing will happen when the user clicks on a column

ie
  <cffunction name="get_servicelist" access="remote" ...>
        <cfargument name="page" required="true">
        <cfargument name="pageSize" required="true">
        <cfargument name="gridsortcolumn" required="true">
        <cfargument name="gridsortdirection" required="true">
        <cfargument name="namesrh" required="true">

         <cfset var qry = "">
         <cfquery name="qry " datasource="....">
                  SELECT ColumnNames, ...
                  FROM   YourTableName
               <cfif len(trim(arguments.gridsortcolumn))>
                   ORDER BY #arguments.gridsortcolumn# #arguments.gridsortdirection#
                </cfif>

         </cfquery>
         <cfreturn queryconvertforgrid(qry , arguments.page, arguments.pagesize) />
    </cffunction>
0
 

Author Comment

by:jfreeman2010
ID: 37812670
I see my problem now.  I did not pass in the gridsortdirection.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 37813688
Well you are passing it into the function.  Whether you're actually using it is a different story ;-)   But I'm very glad you figured it out.  Since you answered your own question, don't forget to select your comment as the answer and close out the thread.
0
 

Author Comment

by:jfreeman2010
ID: 37813703
I did the following, total 11 cols, 9 of then works and 2 did not. the 2 did not sort, 1 is a numeric field and 1 is chars field.

<cffunction name="get_servicelist" access="remote" ...>
        <cfargument name="page" required="true">
        <cfargument name="pageSize" required="true">
        <cfargument name="gridsortcolumn" required="true">
        <cfargument name="gridsortdirection" required="true">
        <cfargument name="namesrh" required="false">

         <cfset var qry = "">
         <cfquery name="qry " datasource="....">
                  SELECT ColumnNames, ...
                  FROM   YourTableName
               <cfif len(trim(arguments.gridsortcolumn)) gt 0>
                   ORDER BY #arguments.gridsortcolumn# #arguments.gridsortdirection#
                </cfif>
         </cfquery>
         <cfreturn queryconvertforgrid(qry , arguments.page, arguments.pagesize) />
    </cffunction>

I got the error message:  error executing db query. [enable debugging by adding 'cfdebug' to your url parameters to see more info].
0
 

Author Comment

by:jfreeman2010
ID: 37813731
I have 2 name fileds, 1 sorted, 1 not.  other 1 is not is a id field, int.  

any suggestion on how to see the error with try to sorting those 2 cols not working?

thanks,
0
 

Author Comment

by:jfreeman2010
ID: 37813736
the cfdebug did not seem helping here.  It did pop up a error message, but did not give any value that will help.
0
 

Author Comment

by:jfreeman2010
ID: 37816292
I see the problem and will able to fix it.  thank you for help!!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now