RegisterSearchFAQ UsergroupsLog in
Sorting Date Object in Scientific Grid

 
Reply to topic    Citra Technologies Forum Index » Report a Bug View previous topic
View next topic

Sorting Date Object in Scientific Grid
Author Message
kannan



Joined: 25 Jul 2008
Posts: 3

Post Sorting Date Object in Scientific Grid Reply with quote
in Scientific Grid ,how can handle the null/Default value while sorting the Date Object. i need to show as Empty and without impact of sorting.provide the solution ASAP..

My Code.
=====
DateRenderer dateRen = new DateRenderer();
ReaderGateTree.setDefaultRenderer(Date.class,dateRen);
DateRenderer dr1 = (DateRenderer) ReaderGateTree.getDefaultRenderer(java.util.Date.class);
java.text.DateFormat df = new java.text.SimpleDateFormat("dd/MM/yyyy HH:mm");
dr1.setDateFormat(df);


DateComparator dc = (DateComparator) stm.getDefaultComparator(Date.class);
dc.setIgnoreTime(false);



Default date should be Empty..JPG
 Description:
'01/01/1900 05:53 ' should be show asempty.
'01/01/1900' is not a valid date.
 Filesize:  16.52 KB
 Viewed:  169 Time(s)

Default date should be Empty..JPG


Wed Feb 11, 2015 7:38 am View user's profile Send private message
support



Joined: 21 Feb 2006
Posts: 1463

Post Reply with quote
Hi,

Why don't you set these dates (1/1/1900) as null?
Wed Feb 11, 2015 9:23 am View user's profile Send private message
kannan



Joined: 25 Jul 2008
Posts: 3

Post Reply with quote
(1/1/1900) or null Dates need to show as EMPTY,how can do,is there any code available in Scientific Grid
Thu Feb 12, 2015 1:56 am View user's profile Send private message
support



Joined: 21 Feb 2006
Posts: 1463

Post Reply with quote
As I said, you can set all these default dates to null.

Alternatively, you can use a custom DateRenderer as follows:

Code:
class DefDateRenderer extends DateRenderer {
   Date defaultDate; //the default date - 1900/1/1
   DateComparator dc; //comparator to compare dates to default
   DefDateRenderer() {
      Calendar cal = new GregorianCalendar();
      cal.set(1900, 0, 1);
      defaultDate = cal.getTime(); //get the default date
      dc = new DateComparator(); //create the comparator
      dc.setIgnoreTime(true); //set it to ignore time
   }
   public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      //set value to null if date is the default
      if (dc.compare(value, defaultDate) == 0) value = null;
      Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
      return c;
   }
}

DateRenderer defRend = new DefDateRenderer();
table.setDefaultRenderer(Date.class, defRend);

Thu Feb 12, 2015 6:06 am View user's profile Send private message
Display posts from previous:    

Reply to topic    Citra Technologies Forum Index » Report a Bug 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