Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Sorting and grouping data in grids

From: ColdFusion 9: AJAX Controls and Techniques

Video: Sorting and grouping data in grids

When you are dealing with a large grid, it's sometimes easier to consume the data if you can sort and group information into logical parts. So let's start by taking a look at the sorting behavior of the cfgrid.cfm file we've worked on in the previous video. So looking at this file at the top, if I hold my mouse over any of these fields, I can click on them and actually sort all the data by that field. If I click on them again, it will reverse the sort order. One thing to keep in mind here, if I click on Art Name, is it's doing some JavaScript sorting that is case-sensitive.

Sorting and grouping data in grids

When you are dealing with a large grid, it's sometimes easier to consume the data if you can sort and group information into logical parts. So let's start by taking a look at the sorting behavior of the cfgrid.cfm file we've worked on in the previous video. So looking at this file at the top, if I hold my mouse over any of these fields, I can click on them and actually sort all the data by that field. If I click on them again, it will reverse the sort order. One thing to keep in mind here, if I click on Art Name, is it's doing some JavaScript sorting that is case-sensitive.

So you'll notice here we have our capital Bs, Cs. If I scroll down to the bottom, you'll see that I have a lowercase c and s way down here. So it's sorting all of my capital values first and then it's sorting my lowercase values. There's nothing really you can do about this. It just something that you need to be aware of when you're using sorting inside of a cfgrid. Now, another thing we can do is actually group our data. If I sort by Artist Name, you can see Aiden Donolan has quite a few pieces of art as well as Austin and Alicia.

We have some very prolific artists in here. It would be nicer if I could see all of Aiden's stuff in one section. So what I want to do here is provide a groupfield attribute. And the groupfield can be any of the columns in my record set. In this case, it's going to be the ArtistName. So I'll go ahead and save my file. We will switch back over to Firefox and reload the page. And now I can see that everything is very nicely grouped by the individual artist names. I have all of Aiden Donolan's stuff here then Austin Weber.

And I can actually collapse these if I don't want to look at them. And it's really, really well done. I can see how many items are in each group. I can also, if I want, actually group by any column. If I click this little down arrow, I can choose Group By This Field. Once I've grouped by that field, I can see that it's now sorting by Price. Here we have two items that are $10,500. I can also choose to Show in Groups or not Show in Groups. If I check that box, I am now back to the original grid display we had.

If I go back over here I can choose Group By This Field. Now, you should notice that it also maintained the previous sections that I had collapsed. So the grid is very smart about taking you right back to where you were, before you started fiddling with things. Now, one other thing that we can do, which may or may not be good depending on your individual situation, is I can actually show and hide columns. Every single column that I have defined by a cfgrid column is actually available to me by clicking the Columns list in any of the drop downs.

So if I'd like to see the Art ID I can turn that on. I can then turn it back off. I decide I don't want the Sold column or the Price. I can really do a lot of interesting things here in order to get everything displaying exactly the way I like it. Now, you will notice that the sorting on a grouped field doesn't actually do anything. When you group something, it's always sorted alphabetically. However, I can sort within my groups. Let me just expand Austln's stuff here. As I change my sorting from ascending to descending, the art pieces change within each individual group.

Now, grouping and sorting a big huge grid like this is handy, but that's not where the real power in the cfgrid is. To really get the most out of a cfgrid, you need to bind it to some data from a cfc, which is just what you'll learn how to do in the next video.

Show transcript

This video is part of

Image for ColdFusion 9: AJAX Controls and Techniques
ColdFusion 9: AJAX Controls and Techniques

35 video lessons · 3124 viewers

Daniel Short
Author

 
Expand all | Collapse all
  1. 2m 41s
    1. Introduction
      59s
    2. Setting up and using the exercise files
      1m 42s
  2. 33m 31s
    1. Using the cfdiv and cfpod tags
      7m 28s
    2. Using the cfwindow tag
      10m 57s
    3. Securing container contents
      3m 38s
    4. Manipulating container contents
      5m 13s
    5. Debugging AJAX behaviors
      6m 15s
  3. 22m 34s
    1. Building tabs
      9m 1s
    2. Building accordions
      5m 49s
    3. Building border layouts
      7m 44s
  4. 42m 13s
    1. Using rich prompts with cfmessagebox
      8m 47s
    2. Uploading files with cffileupload
      8m 52s
    3. Understanding advanced cffileupload
      7m 23s
    4. Building with quick and easy Auto-Suggest
      6m 11s
    5. Using the cfprogressbar tag
      11m 0s
  5. 25m 37s
    1. Binding data to form fields
      8m 54s
    2. Building dependent select menus
      5m 32s
    3. Using cfform in AJAX containers
      3m 52s
    4. Using the cfslider tag
      7m 19s
  6. 37m 31s
    1. Understanding grid basics
      7m 28s
    2. Sorting and grouping data in grids
      3m 34s
    3. Binding data to grids
      5m 35s
    4. Editing data in static grids
      9m 16s
    5. Editing data in bound grids
      11m 38s
  7. 17m 17s
    1. Building a basic tree
      5m 10s
    2. Using query-driven trees
      5m 9s
    3. Binding complex data to a tree
      6m 58s
  8. 16m 4s
    1. Creating a map with markers
      4m 54s
    2. Adding additional markers to a map
      1m 43s
    3. Using custom markers and map controls
      5m 22s
    4. Dynamically populating marker content
      4m 5s
  9. 15m 15s
    1. Accessing CFCs from JavaScript
      8m 56s
    2. Performing asynchronous processing
      4m 22s
    3. Using setForm to submit to a CFC
      1m 57s
  10. 17s
    1. Goodbye
      17s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed ColdFusion 9: AJAX Controls and Techniques.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferences from the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.