Solved

coldfusion cfform cfgrid column sort

Posted on 2012-03-29
19
607 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 12
  • 6
19 Comments
 
LVL 16

Expert Comment

by:Gurpreet Singh Randhawa
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
The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

 
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
 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math (http://www.bennadel.com/blog/197-How-I-Stop-Spammers-On-My-ColdFusion-Blog.htm). While this method is not o…
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

687 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