• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 633
  • Last Modified:

coldfusion cfform cfgrid column sort

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
jfreeman2010
Asked:
jfreeman2010
  • 12
  • 6
1 Solution
 
Gurpreet Singh RandhawaWeb DeveloperCommented:
can u tell what error u are getting or field is disabled or what?
0
 
jfreeman2010Author Commented:
where is no error and when I click on the column hearding, it did not sort the column.
0
 
jfreeman2010Author Commented:
I am try to make the column sort works in this grid.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
_agx_Commented:
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
 
jfreeman2010Author Commented:
I try Firefox's error console and did not see any JavaScript errors.
0
 
jfreeman2010Author Commented:
I also enable ajax debugging in cf administrator and appending the cfdebug on url and not error shows. ):
0
 
_agx_Commented:
Does sorting work for any grids?
0
 
jfreeman2010Author Commented:
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
 
_agx_Commented:
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
 
jfreeman2010Author Commented:
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
 
_agx_Commented:
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
 
jfreeman2010Author Commented:
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
 
_agx_Commented:
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
 
jfreeman2010Author Commented:
I see my problem now.  I did not pass in the gridsortdirection.
0
 
_agx_Commented:
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
 
jfreeman2010Author Commented:
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
 
jfreeman2010Author Commented:
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
 
jfreeman2010Author Commented:
the cfdebug did not seem helping here.  It did pop up a error message, but did not give any value that will help.
0
 
jfreeman2010Author Commented:
I see the problem and will able to fix it.  thank you for help!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 12
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now