Solved

coldfusion cfform cfgrid column sort

Posted on 2012-03-29
19
598 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 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
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 
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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

821 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