House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Search cf-talk

July 04, 2009

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
       1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31   

Home /  Groups /  ColdFusion Talk (CF-Talk)

Point me in the right direction - expand a category from a query

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Les Mizzell
01/08/2009 04:07 PM

I've *finally* gotten my main client to upgrade to CF8. So, up until this point, I've not really had time to dive into it too deep and am just learning my way around the new stuff. Ok, I've got an admin page with a number of records sorted by categories set up like this (cfouput with "group") GROUP 1     Item A - [edit][delete][preview]     Item B - [edit][delete][preview]     Item C - [edit][delete][preview] GROUP 2     Item A - [edit][delete][preview]     Item B - [edit][delete][preview] ...... Blah, blah... What's the best way to collapse the sub items so when you first visit the page you just see the groups - click a group and it expands to show the categories with edit buttons and such underneath. I know there's a dozen CSS or javascript ways to do it. Is there anything in CF8 built in that would make it easier. Looks like cftree would be close maybe? If not, no problem. I just go back to my other methods.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Adrian Lynch
01/08/2009 06:07 PM

I'd do it with jQuery. Here's a sample if you're using tables: <style type="text/css">   table, tr, td {     border-collapse: collapse;     border: solid 1px #ccc;     padding: 5px;   }   .group {     cursor: pointer;   }   .item {     display: none;   } </style> <script type="text/javascript" src="/scripts/jquery-1.2.6.min.js"></script> <script type="text/javascript">   $(function() {        $(".group").click(function() {       var groupID = getID(this.id);       var items = $(".group-" + groupID);       items.toggle();     });      });      function getID(input) {     return input.split("-")[1];   } </script> <table>   <tr><td colspan="2" class="group" id="group-1">GROUP 1</td></tr>   <tr class="item group-1">     <td>Item A</td>     <td>[edit][delete][preview]</td>   </tr>   <tr class="item group-1">     <td>Item B</td>     <td>[edit][delete][preview]</td>   </tr>   <tr class="item group-1">     <td>Item C</td>     <td>[edit][delete][preview]</td>   </tr>   <tr><td colspan="2" class="group" id="group-2">GROUP 2</td></tr>   <tr class="item group-2">     <td>Item A</td>     <td>[edit][delete][preview]</td>   </tr>   <tr class="item group-2">     <td>Item B</td>     <td>[edit][delete][preview]</td>   </tr> </table> ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Les Mizzell
01/09/2009 08:19 PM

Adrian Lynch wrote: > I'd do it with jQuery. Here's a sample if you're using tables: Oooo - that works a charm! Jezz, why haven't I been doing this before!!! Thanks!!!

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Adrian Lynch
01/10/2009 07:42 AM

You wouldn't be the first person to have said that, nor the last! jQuery is awesome! Adrian ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Adrian Lynch
01/08/2009 06:15 PM

Or a simpler example with no extra classes or IDs, just targeting of the elements: <style type="text/css">   h3 {     cursor: pointer;   }   div div {     border: solid 1px #ccc;     padding: 3px;     display: none;   } </style> <script type="text/javascript" src="/shared/scripts/jquery-1.2.6.min.js"></script> <script type="text/javascript">   $(function() {        $("h3").click(function() {       $(this).siblings("div").toggle();     });      }); </script> <div>   <h3>GROUP 1</h3>   <div>Item A [edit][delete][preview]</div>   <div>Item B [edit][delete][preview]</div>   <div>Item C [edit][delete][preview]</div> </div> <div>   <h3>GROUP 2</h3>   <div>Item A [edit][delete][preview]</div>   <div>Item B [edit][delete][preview]</div> </div> Adrian Building a database of ColdFusion errors at http://cferror.org/ ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Dominic Watson
01/08/2009 06:30 PM

Yeh, I'm with Adrian, though whatever js library you're most familiar with will do. If there is a CF tag for doing this it would either be outputting some javascript or a generating flash which, while good for quick solutions, doesn't really fit into a long-term client-side way of coding in my opinion; there simply isn't the completeness or flexibility that is offered from the various js libraries. Also, as Adrian demonstrated; with a working knowledge of any of the libraries, not using CF for such things is really just as quick and simple. Truly seperating display logic and business logic, added with crossing the js noob / js journeyman border is quite a light-bulb moment I think. My tuppence, Dominic

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Steve Lichtenberg
01/09/2009 07:48 AM

The easiest library I have found to accomplish this is HTMLXtree. They have a good set of other widgets (tabs, editors etc) but the tree view is excellent.  You can set it to output only the trunk nodes and query later for the leaves as a user opens the folder.  It also allows for custom graphics and includes a folder metaphor and character listing (+/_ graphics). There is a free version that doesn't handle XML output or a paid version that does.  There is a slight learning curve but overall very powerful and easy to use.  Support is excellent as well.  Just post your questions and within a day someone will answer. --S   ^ On Thu, Jan 8, 2009 at 6:21 PM, Dominic Watson <watson.dominic@googlemail.com> wrote: ----- Excess quoted text cut - see Original Post for more -----


<< Previous Thread Today's Threads Next Thread >>

Mailing Lists