We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23044
    • 20 Posts
    I’ve struggled through several data widgets so far and am now experiencing a problem with the data pager. I have a page (www.nokomisfootball.org/stats.html) that contains 5 different temlate variables that display football stats from the DB. So far all other template variables I have created using datagrid widgets have a very simple SQL select statement i.e.
    @select * from modx_roster;
    which works as expected. The stats I’m pulling from the DB gets the player name from one table and several columns from another table. The select looks like such:
    @select r.name, ds.solo, ds.assist, ds.sacks, ds.fumble, ds.interceptions, ds.touchdowns 
    from modx_roster as r, modx_defenseStats as ds 
    where r.id = ds.playerId 
    order by ds.playerId asc;
    The query returns exactly what I’d expect and the datagrid displays the first 5 records (as designated) and has the appropriate number of page links at the bottom. The problem occurs when one clicks a link to go to, say, page 2. The page loads but displays the same 5 records (first 5). Does anyone have a suggestion? If I set the page size > number of rows in the result set all rows are displayed, so I’m stumped.

    Thanks for any ideas you might have
      • 23044
      • 20 Posts
      ++Bump

      Nobody has a clue huh?
        • 26016
        • 561 Posts
        Quote from: perlmonger at Sep 07, 2006, 09:19 PM

        I’ve struggled through several data widgets so far and am now experiencing a problem with the data pager. I have a page (www.nokomisfootball.org/stats.html) that contains 5 different temlate variables that display football stats from the DB. So far all other template variables I have created using datagrid widgets have a very simple SQL select statement i.e.
        @select * from modx_roster;
        which works as expected. The stats I’m pulling from the DB gets the player name from one table and several columns from another table. The select looks like such:
        @select r.name, ds.solo, ds.assist, ds.sacks, ds.fumble, ds.interceptions, ds.touchdowns 
        from modx_roster as r, modx_defenseStats as ds 
        where r.id = ds.playerId 
        order by ds.playerId asc;
        The query returns exactly what I’d expect and the datagrid displays the first 5 records (as designated) and has the appropriate number of page links at the bottom. The problem occurs when one clicks a link to go to, say, page 2. The page loads but displays the same 5 records (first 5). Does anyone have a suggestion? If I set the page size > number of rows in the result set all rows are displayed, so I’m stumped.

        Thanks for any ideas you might have
        Hi, That’s a nice-looking page.

        I looked at your site, and scratched my head until I noticed that said you were using 5 template variables. I’m reasonably confident that this may affect your paging. (I’m using just one TV for my page) If you have a Datagrid for each TV, each one has its own settings. I think I see what you mean... several TV’s have additional data, and clicking those links does nothing. I’m pretty sure you can’t combine 5 TV’s, each with its own separate Datagrid, and get them to blend with each other with correct paging. [someone let me know if this is wrong].

        My first thought was that you could try combining the TV’s into a single one, and control paging with its Datagrid, particularly Page Size, which refers to number of rows. Hmmm...it occurred to me, though, that this would clobber your headings for each item, so that’s no good.

        My next thought would be to set Page Size to zero for each TV, which displays all records with no paging. Possibly useful at times! You’d get all data, but this would give you a page that was so long is would be gross. Or maybe that would be OK. smiley

        OK, how about this... under the Stats link, you have sub-links for Passing, Rushing, etc. Then each of those link/pages will have its own TV instead of all five. I’m guessing paging will work fine when you do that, you just won’t have all categories on one page.

        Hope that helps.

        Good luck!
          MODx and Wordpress development
          Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
          • 23044
          • 20 Posts
          I’ve since come to that same conclusion. Thanks for the thoughts though. I’m now trying to figure out how to do this with AJAX. I was thinking if each TV was in it’s own <div> I could have the contents of the div (TV) updated via AJAX. I haven’t figured out how to do this yet but I’m just starting to look for a solution. I’m sure someone out there has used more than one datagrid on a page before, I just need to find the answer.

          Thanks again.
            • 26016
            • 561 Posts
            Quote from: perlmonger at Sep 11, 2006, 03:20 PM

            I’ve since come to that same conclusion. Thanks for the thoughts though. I’m now trying to figure out how to do this with AJAX. I was thinking if each TV was in it’s own <div> I could have the contents of the div (TV) updated via AJAX. I haven’t figured out how to do this yet but I’m just starting to look for a solution. I’m sure someone out there has used more than one datagrid on a page before, I just need to find the answer.

            Thanks again.
            I don’t know AJAX yet, but that sounds reasonable! I look forward to hearing what others might have done, or what you manage to do.

            My Datagrid use has been more simple in nature. I’ve sort of become the de facto Datagrid debugger, having squashed two bugs so far, the "empty record display" problem, and the "URL in table cell" problem. That’s mainly because there isn’t really any documentation, the handy Widget interface notwithstanding, and I think the author has moved on to more pressing issues concerning the architecture of the 1.0 release.

            I’ve also gotten quite far into MakeTable, the database display snippet which may, in fact, be more flexible than Datagrid, but it does have a learning curve if you really want to tweak it. Its most immediate benefit that comes to mind is column sorting.

            Hope you figure it out!
              MODx and Wordpress development
              Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
              • 23044
              • 20 Posts
              I started to look at the Make Table snippet but got side-tracked and went with datagrid since I could get something up quickly. Do you have any information that you care to share about the Make Table snippet? (examples, code, etc) What I really want is something similar to the data grid widget available in most current Javascript libraries like OpenRico, Dojo, etc. Something that has the option of scrolling, sortable columns, edit in place, add record (if logged in), delete record (if logged in), etc. Yeah, I want it all.... never hurts to want I guess. I think I’ll try to implement something from OpenRico or Mochikit or something like that. Now I’m going to have to spend countless hours test-driving Javascript libraries to decide which one to use. I haven’t experimented much with these yet, just played with prototype and scriptaculous to date. Once again, if anyone has been successful with what I’m trying to do, please shout it out.

              Thanks samba.
                • 26016
                • 561 Posts
                Quote from: perlmonger at Sep 11, 2006, 04:12 PM

                I started to look at the Make Table snippet but got side-tracked and went with datagrid since I could get something up quickly. Do you have any information that you care to share about the Make Table snippet? (examples, code, etc) What I really want is something similar to the data grid widget available in most current Javascript libraries like OpenRico, Dojo, etc. Something that has the option of scrolling, sortable columns, edit in place, add record (if logged in), delete record (if logged in), etc. Yeah, I want it all.... never hurts to want I guess. I think I’ll try to implement something from OpenRico or Mochikit or something like that. Now I’m going to have to spend countless hours test-driving Javascript libraries to decide which one to use. I haven’t experimented much with these yet, just played with prototype and scriptaculous to date. Once again, if anyone has been successful with what I’m trying to do, please shout it out.

                Thanks samba.
                Perl,
                Fascinating ideas! Yes, to get something up quick, Datagrid is the one.

                Let’s see about MakeTable, based on your wish list...

                There is javascript stuff that allows you to change the "# of records displayed". I disabled that for my app - won’t really be useful because not an enormous # of recs. Nothing for scrolling per se, if I recall.

                Sortable columns, yup, you tell which columns you want to display and which ones to sort.

                So far, I don’t think there are add/delete/change capabilities in there, strictly display and re-sort. [there seems to be planned code in Datagrid for sorting, but I don’t think it ever got implemented, so I just took care of that with ORDER BY clauses].

                OK... here’s a recap of what I did to MakeTable. Lots of care and feeding! PM me if you need details.
                In the Snippet:
                - I changed it to be fed by a URL parm for part of the query.
                - I hardcoded the maxPageSize.
                - I tweaked the main query for my purposes including use of my parm.
                - I also tweaked the query used for pagination to use the parm.
                - I chose the fields to display.
                - I added my parm to the qualifier for OrderByLink.
                - I selected which fields to sort on.
                - I added the parm to the createPagingNavigation part (a gotcha!).

                In the Class:
                - I commented out the Javascript stuff for "# or records" choice.
                - I added CSS classes to a few things for display tweaking.
                - I found there were bunches of CSS ID’s and classes that needed to be added to my template; there was no CSS example provided with the class and snippet. This is a gotcha that you see when the table looks kind of plain.
                - in the OrderByClause I set up a default sort order. [It would be nice to simply set this from the snippet].
                - I changed a line of code to work without friendly URL’s. See 2nd find on "documentIdentifier".

                You may not want to do all that! wink

                OpenGeek is the guy who wrote MakeTable, and he can speak with the most authority on it. If you’re really interested in MakeTable, perhaps a new thread is warranted, or a PM to OpenGeek. He’s a very smart fellow.
                  MODx and Wordpress development
                  Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  I wrote an editable datagrid based on an asp .net tutorial that I found; it’s still kind of flaky, but the general idea works pretty well. Maybe the code will help you out. It’s a module, so there’s no user verification code, but that’s easy enough to add to the .php files.

                  The module itself only includes the database.php file, and has these configuration settings:
                  &modId=Module ID;int;6 &modPath=Path;string;../assets/modules/database3
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 23044
                    • 20 Posts
                    Thanks Samba and Susan,
                    You guys are great! I now have two possible solutions to the problem. I spent some time yesterday looking into AJAX datagrid components from about a hundred sources and am considering trying to implement one of them. I think with Susan’s code and the Make Table bit as a reference, It might be possible. I’m not a PHP guru but have strong Perl/Java skills so I think I can make the leap to PHP without too much difficulty. I’m pretty clueless as far as AJAX goes but it looks pretty straight-forward. The datagrid widget is really a pretty good component. I just want a little more functionality. Maybe we can come up with something a little more robust. I’ll try to get something going this week and let you know how it goes.

                    Thanks much
                      • 26016
                      • 561 Posts
                      Susan,
                      You’re fantastically helpful, as always! I’ll have a look at your code. Thanks again.

                      Perl,
                      I look forward to seeing what you come up with, too. Of course, you’ll probably want to name it Gridiron Grids. grin BTW, your idea of having extra DIV’s intrigues me, and I’m going to store that away for use at some point when I’m needing specialized control of displaying several things. Fortunately, simply having everything go into [*content*] works most of the time. AJAX will probably be my next stop on the learning journey as well.

                      Thanks, all!
                        MODx and Wordpress development
                        Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4