RegisterSearchFAQ UsergroupsLog in
PopupFilterHeaderModel for filtering Date

 
Reply to topic    Citra Technologies Forum Index » Technical Support - Evaluation View previous topic
View next topic

PopupFilterHeaderModel for filtering Date
Author Message
Michael Kuettner



Joined: 01 Feb 2007
Posts: 23
Location: Dresden

Post PopupFilterHeaderModel for filtering Date Reply with quote
I want to filter and sort a table column that contains Date objects (or GregorianCalendar). The existing filter and sort does only include year, month and day but i need a more detailed filtering of Date objects up to seconds.

Therefor also the appearance of the popup combo box in the table header has to be changed. For Date columns this combo box shows items like: Aug 13, 2007 but i need something like: Aug 13, 2007 10:15:00 PM

How can i achieve this?
Mon Aug 13, 2007 3:24 am View user's profile Send private message
support



Joined: 21 Feb 2006
Posts: 1463

Post Reply with quote
Hi,

Have a look at this post:

http://www.citra-tech.com/forum/viewtopic.php?t=58

, which describes how to install a different renderer for the popup filter combobox. The topic also describes how to customize the appearance of the combobox in the custom filter panel.
Mon Aug 13, 2007 3:44 am View user's profile Send private message
Michael Kuettner



Joined: 01 Feb 2007
Posts: 23
Location: Dresden

Post Reply with quote
Well, this was exactly my question!
Thanks!
Mon Aug 13, 2007 4:32 am View user's profile Send private message
support



Joined: 21 Feb 2006
Posts: 1463

Post Reply with quote
There is a faster way to do this as I noticed, since the combobox's renderer is a com.sciapp.renderers.PopupRenderer. In order to change the appearance of date objects, all you need to do is change PopupRenderer's dateFormat.

e.g.

Code:
PopupFilterHeaderModel m = new PopupFilterHeaderModel();
PopupRenderer pr = (PopupRenderer) m.getComboBox().getRenderer();
pr.setDateFormat(newDateFormat);

Mon Aug 13, 2007 4:36 am View user's profile Send private message
Michael Kuettner



Joined: 01 Feb 2007
Posts: 23
Location: Dresden

Post Reply with quote
This would help to change the appearance of the PopupComboBox. But also the sorting of simple Date objects does not take care of hours, minutes or seconds of the given Date object. It seems that only year, month and day are used for comparing Dates.

Now i use GregorianCalendar with a own Renderer for PopupComboBox and table. This works fine!
Mon Aug 13, 2007 6:41 am View user's profile Send private message
support



Joined: 21 Feb 2006
Posts: 1463

Post Reply with quote
By default, the date comparator ignores time when comparing two dates.
To change that:

Code:
DateComparator dc = (DateComparator) sortTableModel.getDefaultComparator(Date.class);
dc.setIgnoreTime(false);


For filtering, DateFilter also has a DateComparator that you need to change.
Mon Aug 13, 2007 6:51 am View user's profile Send private message
navTeam2



Joined: 14 Jan 2011
Posts: 97

Post Reply with quote
Hi again,

After upgrading to version 4.0.5, we had trouble with the code
Code:

      EditableCustomPopupFilterHeaderModelAmeliore cpfhm = new EditableCustomPopupFilterHeaderModelAmeliore();
      cpfhm.setAutoFilter( new CustomAutoFilter() );
      PopupRenderer pr = (PopupRenderer) cpfhm.getComboBox().getRenderer();
      pr.setDateFormat( new SimpleDateFormat("dd/MM/yy"));


What's the new way of doing this ?

Thanks in advance

NavTeam
Tue Jan 31, 2012 8:55 am View user's profile Send private message
support



Joined: 21 Feb 2006
Posts: 1463

Post Reply with quote
Try creating and assigning a new popuprenderer:

Code:
PopupRenderer pr = new PopupRenderer();
pr.setDateFormat(new SimpleDateFormat("dd/MM/yy"));
cpfhm.getComboBox().setRenderer(pr);

Tue Jan 31, 2012 9:54 am View user's profile Send private message
navTeam2



Joined: 14 Jan 2011
Posts: 97

Post Reply with quote
Thanks it works.
But for my knowledge, the popup renderer installed by default is no longer a PopupRenderer. So what features will we lose by setting the old school "PopupRenderer" ?

Thanks

NavTeam
Wed Feb 01, 2012 3:27 am View user's profile Send private message
support



Joined: 21 Feb 2006
Posts: 1463

Post Reply with quote
It is and it isn't. The default renderer is indeed a PopupRenderer. However, it is being masked by a non-PopupRenderer for displaying checkboxes in the popup menu list. When you assign the "old school PopupRenderer", as you put it, you don't loose any features, since it is the same thing that we do in our code.

This is not evident yet, but this is how it works. We are going to expose the checkbox popup menu to the public API soon, and everything will become clear. Then, you will not have to create and assign a new PopupRenderer but you will be able to get the already installed, as you did before but with a different method call, and set a new date format. At the same time, using the code above, will make no difference, besides the instantiation of a new object, which could have been avoided.
Wed Feb 01, 2012 4:50 am View user's profile Send private message
navTeam2



Joined: 14 Jan 2011
Posts: 97

Post Reply with quote
Ok, it's all clear for me. Thanks for your answer
NavTeam
Wed Feb 01, 2012 5:10 am View user's profile Send private message
Display posts from previous:    

Reply to topic    Citra Technologies Forum Index » Technical Support - Evaluation All times are GMT - 5 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group