gwt - CellTable with Date Column -
i trying build celltable widget time tracking. first column must represent days current month in following form
fri, 1 sat, 2 sun, 3 mon, 4 tue, 5 …
etc. till end of month (28 -31 rows).
my code looks that:
column<rec,string> daycolumn = new column<rec,string>(new textcell()) { @override public string getvalue(rec rec) { daynr = datetimeformat.getformat( "ee,d" ).format(new date()); return daynr; } }; table.addcolumn(daycolumn, "date");
so can see in column today-date in cells. how can days of month (1...28/30/31) in column each in own cell?
it ideal if prepared list of rec items date variable.
declaring rec pojo date
class rec{ date date; //getter , setters. }
populate list of rec items
list<rec> recitems = new arraylist<rec>(); date = new date(); int nowmonth = now.getmonth(); int nowyear = now.getyear(); list<date> listofdatesinthismonth = new arraylist<date>(); date beginningofmonth = new date(nowyear,nowmonth,1); date beginningofnextmonth = new date(nowyear,nowmonth+1,1); date start = beginningofmonth; while(start.before(beginningofnextmonth)){ listofdatesinthismonth.add(start); start = new date(nowyear,nowmonth,start.getdate()+1); } for(date date:listofdatesinthismonth){ rec recitem = new rec(); recitem.setdate(date); recitems.add(recitem ); }
rendering
column<rec,string> daycolumn = new column<rec,string>(new textcell()) { @override public string getvalue(rec rec) { daynr = datetimeformat.getformat( "ee,d" ).format(rec.getdate()); return daynr; } };
Comments
Post a Comment