Select to view content in your preferred language

Filter widget use date calendar as default click

2316
7
Jump to solution
02-15-2018 09:46 AM
AndrewL
Frequent Contributor

I am using the filter widget to filter dates. I would like to remove the today, tomorrow, yesterday options and have it direct to the calendar picker immediately when a user clicks on the dropdown box. I am using WAB 2.7 but I am using the Filter widget folder from 2.4 because I prefer the "Apply" button as opposed to the toggle button.

I commented out some code to where I see only the "the date..." option. However, the user still needs to select "the date..." from the dropdown before the calendar pops up. 

The code I commented out is from:   \apps\2\jimu.js\dijit\_filter\DateValueSelector.js   The code I commented out are lines 55 through 62 and line 42. Thank you.

//virtualDates: null,//['today', 'yesterday', 'tomorrow'] 

//if(!(this.virtualDates && this.virtualDates.length > 0)){ 
//this.virtualDates =
//[filterUtils.VIRTUAL_DATE_TODAY, filterUtils.VIRTUAL_DATE_YESTERDAY, filterUtils.VIRTUAL_DATE_TOMORROW];
// }
//this.dateTypeSelect.addOption({
//value: '',
//label: ' '
//}); END Comment

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Andrew,

   OK, there needs to be a change in the DateValueSelector.js postCreate function as well.

Add line 6

...
          this.dateTypeSelect.addOption(option);
        }));

        this._showDateTypeSelect();
        this.dateTypeSelect.set('value', 'custom', false);
...

View solution in original post

7 Replies
RobertScheitlin__GISP
MVP Emeritus

Andrew,

   You really do not need any of the code you did. Here is whats needed:

Add these new rules to the filter widgets css\style.css file

.jimu-date-value-selector .custom-date-text-box {
  height: 30px !important;
  visibility: visible;
}

.date-type-select.restrict-select-width{
  display: none;
}
AndrewL
Frequent Contributor

Works great! Thank you. I uncommented out the previous code. I always tend to go digging into the JS code but I really should pay more attention to the css code.

0 Kudos
AndrewL
Frequent Contributor

Actually, I spoke too soon. The calendar picker works, but when I apply the filter the filtering of the layer does not work. The format of the date is different with the new CSS code so I am not sure if that has something to do with it.

With original CSS code:

 

 

With new CSS code:

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Andrew,

  Try changing the second css rule to this one:

.date-type-select.restrict-select-width{
  visibility: hidden;
}
0 Kudos
AndrewL
Frequent Contributor

No sorry filter still not working. No console errors.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Andrew,

   OK, there needs to be a change in the DateValueSelector.js postCreate function as well.

Add line 6

...
          this.dateTypeSelect.addOption(option);
        }));

        this._showDateTypeSelect();
        this.dateTypeSelect.set('value', 'custom', false);
...
AndrewL
Frequent Contributor

Yep! That did it. Thank you. Great work.

0 Kudos