We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30564
    • 60 Posts
    Hi all, forgive me having rummaged, I can’t find an answer to this, so is there an out of the box method to populate a data grid from ditto? The idea would be to create an user sortable element, i.e. user clicks on header and data is sorted by that criteria, click on another and the grid is resorted.

    Regards
    PS Might I respectfully suggest that the default format, in language file, would benefit from a [&nbsp] before the ’by’ to maintain formatting.
      • 4749
      • 623 Posts
      I was able to use Ditto to populate a table then use the existing mootools js and create a super fast and flexible sortable table. It’s pretty sweet. It even works with pagination. It’s currently on a development site now, I’ll post it when it’s finished.

      Anyhow, here’s the link for the js:
      http://madhatted.com/assets/2008/1/16/minimal_sort_v2.js
      and the link to the explanation:
      http://madhatted.com/2008/1/16/the-joy-of-an-optimized-complete-javascript-table-sort
      and here’s the link to the example:
      http://madhatted.com/assets/2008/1/16/minimal_sort_v2_1.html

      Just make sure you use cursor: pointer; in the css for the th elements so the user knows that they’re clickable. A big thanks to Matthew Beale at Madhatted for his great script.
        The MODx has you...
        Utah Web Design
        • 29076
        • 615 Posts
        Wow, this is just great! I really need this. Thanks. laugh
          I think, thererfor I am! But what I am, and why...?
          • 29076
          • 615 Posts
          Here is a working example on the sorting-function. The table loads a little slow, specially in MSIE, but that’s because the Table mouseover script, not the sorting script.
            I think, thererfor I am! But what I am, and why...?
            • 10076
            • 1,024 Posts
            did you do that using the above script? How do you get the images there?
              • 29076
              • 615 Posts
              Yes, I used the scripts in the example.

              The images is somhow hardcoded by a spesific namesystem in my image folder hierarchy. The Ditto-template is like this:
              <tr class="alt">
                 <td><a href="[~[+id+]~]">[+pagetitle+]</td>
                 <td>[+norwegian+]</td>
                 <td class="imageCell" width="75px"><img class="listImgLeft" src="assets/images/species/[+description+]/[+description+]_close_mini.jpg"  /><img src="assets/images/species/[+description+]/[+description+]_hole_mini.jpg" /></a>
                 </td>
              </tr>
                I think, thererfor I am! But what I am, and why...?
                • 4749
                • 623 Posts
                @Sylvaticus:
                That’s almost exactly how I set it up too. My Tpl is very similar, but my list is paginated and works across the pagination too. Your implementation looks good BTW. Simple wasn’t it? All you have to do is change a few id’s here and there and that’s it. Good use of the script.
                  The MODx has you...
                  Utah Web Design
                  • 29076
                  • 615 Posts
                  Yes, it was wery simple, and I wery glad you shared the solution with us. Thanks again! laugh
                    I think, thererfor I am! But what I am, and why...?
                    • 4749
                    • 623 Posts
                    Well, not really my solution. I was just lucky enough to stumble upon a solution that I could use. This is exactly why I love opensource - the community can grow together. I learn new things everyday!
                      The MODx has you...
                      Utah Web Design
                      • 29076
                      • 615 Posts
                      Quote from: cbaone at May 23, 2008, 10:28 AM

                      Well, not really my solution.
                      Thats OK, and I putted a link back to the original in my template.
                        I think, thererfor I am! But what I am, and why...?