We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40041
    • 36 Posts
    Anyone have an example of how to get the new date filters to work?

    Example "getlist-where" for a text filter:
    {"download_title:LIKE":"%[[+docFilter]]%"}

    What's needed to make the date filter work?

    Also - I can't seem to get any of my filter labels to show up on my CMP. Is it not as simple as just filling in the "Label" field???
      • 4172
      • 5,888 Posts
      Here's an example within migxCalendars:

      https://github.com/Bruno17/migxCalendars/blob/master/core/components/migxcalendars/migxconfigs/migxcalendar_events.config.js#L257

      you will need this snippet to generate the query:
      https://github.com/Bruno17/MIGX/blob/master/core/components/migx/elements/snippets/preparedatewhere.snippet.php

      your datefields should be of type datetime and named startdate and enddate and have valid values (enddate > startdate) in both fields.

      or better the newest packate (2.6.8-rc4)
      https://github.com/Bruno17/MIGX/tree/master/packages


      Labels are not displayed on the CMP.
      I'm allways using self-explaining empty - texts.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 40041
        • 36 Posts
        Ouch!

        I followed this tutorial here to get where I am:

        http://www.youtube.com/watch?v=Dv83iC9iELI

        I don't see anything that makes much sense to me at your link smiley Might be further down the rabbit hole than I want to go.

        My table that I want to sort on has one timestamp field. I just wanted to be able to filter it between two selected date filters...
          • 4172
          • 5,888 Posts
          the date-filter has one date-field and a selectbox with = >= <=
          which lets you select events ending at the selected date, beginning at the selected date or are running at the selected date.
          Its possible to have modified snippet to filter by one field, of course.

          For two date-fields, you would need a custom-made filterbox, which do something like that, but with two date-fields and without the listbox:
          https://github.com/Bruno17/MIGX/blob/master/core/components/migx/configs/grid/grid.config.inc.php#L217
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 40041
            • 36 Posts
            Even further down the hole for me sir...

            Thanks anyways smiley
              • 40041
              • 36 Posts
              Quote from: Bruno17 at Mar 11, 2014, 10:18 AM
              the date-filter has one date-field and a selectbox with = >= <=
              which lets you select events ending at the selected date, beginning at the selected date or are running at the selected date.
              Its possible to have modified snippet to filter by one field, of course.

              For two date-fields, you would need a custom-made filterbox, which do something like that, but with two date-fields and without the listbox:
              https://github.com/Bruno17/MIGX/blob/master/core/components/migx/configs/grid/grid.config.inc.php#L217

              Sorry - I'm trying to understand this - should I be replacing the migx file I have with the contents of this file you've linked to?
                • 4172
                • 5,888 Posts
                you would need another additional new filter, with two datefields, which I could add to this file for the next coming version.
                This is the one, which creates the datefilter with the listbox:

                $gridfilters['date']['code']="
                {
                xtype: 'compositefield',
                width: 300,
                items: [
                {
                xtype: 'modx-combo'
                ,id: '[[+name]]-migxdb-search-filter'
                ,name: '[[+name]]'
                ,hiddenName: '[[+name]]'
                ,url: '[[+config.connectorUrl]]'
                ,fields: ['combo_id','combo_name']
                ,displayField: 'combo_name'
                ,valueField: 'combo_id'
                ,pageSize: 0
                ,value: 'all'
                ,baseParams: {
                action: 'mgr/migxdb/process',
                processaction: 'getdatecombo',
                configs: '[[+config.configs]]',
                searchname: '[[+name]]',
                resource_id: '[[+config.resource_id]]'
                }
                ,listeners: {
                'select': {
                fn: function(tf,nv,ov){
                var s = this.getStore();
                s.baseParams.[[+name]]_dir = tf.getValue();
                this.filter[[+name]](tf,nv,ov);
                },
                scope: this
                }
                }
                },
                {
                xtype : 'datefield',
                id: '[[+name]]-migxdb-search-filter-date'
                ,name: '[[+name]]_date'
                ,format: 'Y-m-d'
                ,listeners: {
                'select': {
                fn: function(tf,nv,ov){
                var s = this.getStore();
                s.baseParams.[[+name]]_date = tf.getValue();
                this.filter[[+name]](tf,nv,ov);
                },
                scope: this
                }
                }
                }
                ]
                }
                ";
                
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 43864
                  • 151 Posts
                  Quote from: Bruno17 at Mar 11, 2014, 12:46 PM
                  you would need another additional new filter, with two datefields, which I could add to this file for the next coming version.
                  This is the one, which creates the datefilter with the listbox:

                  $gridfilters['date']['code']="
                  {
                  xtype: 'compositefield',
                  width: 300,
                  items: [
                  {
                  xtype: 'modx-combo'
                  ,id: '[[+name]]-migxdb-search-filter'
                  ,name: '[[+name]]'
                  ,hiddenName: '[[+name]]'
                  ,url: '[[+config.connectorUrl]]'
                  ,fields: ['combo_id','combo_name']
                  ,displayField: 'combo_name'
                  ,valueField: 'combo_id'
                  ,pageSize: 0
                  ,value: 'all'
                  ,baseParams: {
                  action: 'mgr/migxdb/process',
                  processaction: 'getdatecombo',
                  configs: '[[+config.configs]]',
                  searchname: '[[+name]]',
                  resource_id: '[[+config.resource_id]]'
                  }
                  ,listeners: {
                  'select': {
                  fn: function(tf,nv,ov){
                  var s = this.getStore();
                  s.baseParams.[[+name]]_dir = tf.getValue();
                  this.filter[[+name]](tf,nv,ov);
                  },
                  scope: this
                  }
                  }
                  },
                  {
                  xtype : 'datefield',
                  id: '[[+name]]-migxdb-search-filter-date'
                  ,name: '[[+name]]_date'
                  ,format: 'Y-m-d'
                  ,listeners: {
                  'select': {
                  fn: function(tf,nv,ov){
                  var s = this.getStore();
                  s.baseParams.[[+name]]_date = tf.getValue();
                  this.filter[[+name]](tf,nv,ov);
                  },
                  scope: this
                  }
                  }
                  }
                  ]
                  }
                  ";
                  

                  Hey Bruno17, I know this is an older post, but I'm now in a situation where I want to filter between 2 dates. I already have a filter using preparedatewhere, but I don't understand how to modify it to select between 2 dates. Can you help please? I can't find any documentation on how to do this.