We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19328
    • 433 Posts
    It would be nice if we could add a custom dropdown filter field that is permanently displayed above the grid, so clients can use it to filter the resources.

    Use case example: we have a grid that is filled with static resources. Each static resource has a user id saved in the link_attributes field (for convenience, but could also be a TV). We would like to place a dropdown list above the grid which lists all users from specified user groups. When selecting a user, the grid should update to show only the resources which have the user id of the selected user in the link_attributes field. This filter should be set in advance by the site admin, so other site users don't have to create the filter themselves.

    Steps involved would be (I think):
    1) choosing what is displayed in the dropdown list (in this case the users from specified usergroups - could be multiple groups). Or just all users if that's easier. And in what way, like username==id
    2) choosing what 'where' filter has to be applied. In this case: get all resources where link_attributes = user id.

    Would this be difficult to implement? Would you think of adding this?
    I've added a mockup of what it could look like.

    This question has been answered by goldsky. See the first response.

    [ed. note: michelle84 last edited this post 9 years, 6 months ago.]
    • discuss.answer
      Thx for bringing the use case.
      This the answer for your question:
      http://rtfm.modx.com/extras/revo/gridclasskey#GridClassKey-Settings-Containers-Settings-Example-1

      Let me know if you have any confusion laugh
        Rico
        Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
        MODx is great, but knowing how to use it well makes it perfect!

        www.virtudraft.com

        Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

        Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

        Maintainter/contributor of Babel

        Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.
        • 19328
        • 433 Posts
        Many thanks, Rico! I will check out your solution.

        When there is any confusion, I'll let you know.
          • 19328
          • 433 Posts
          Hi Rico, thanks again for your tutorial, it's working great for the user list!

          However I'm now trying to do something that should be simpler (this is so useful for many projects!), but I can't wrap my head around it. In a different grid class key resource I list resources which have one or more categories set based on a SmartTag TV named 'categories'. I would now like to create a dropdown combobox for the gridclasskey to filter the resources by category.

          I think the only file that is really different from your tutorial for the users is the getlist.class.php file, am I correct? But I'm not sure what to put in this file to list the categories from the smarttag tv. I'm not really familiar yet with developing extras. Is the getlist.class.php file only used to fill the dropdown (and should it just list all the values from the smarttag tv) or do I have to join the resources already in this file to only show the categories that have been assigned to the resources in the grid?

          Could you maybe give me a starting point? smiley
          • You need to modify these on the custom JS file:
                    // this goes to a custom connector, to refer the custom path of the processor
                    url: MODx.config.base_url + 'assets/components/customize-gck/connector.php'
                    , baseParams: {
                        action: 'authors/getlist'
                    }
                    , fields: ['id', 'name']
            

            Then you need to create the Class file to get the values from the TV.
            On the "getlist.class.php", you need to change its
            public $classKey = 'modTemplateVarResource';

            to
            public $classKey = 'smarttagTags';

            and leftJoin to the smarttagTagresources and leftjoin to modTemplateVar where the modTemplateVar.id is the TV you are referring to.
            Make it distinct.
              Rico
              Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
              MODx is great, but knowing how to use it well makes it perfect!

              www.virtudraft.com

              Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

              Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

              Maintainter/contributor of Babel

              Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.