gwt celltable - GWT sinkEvents in hosted mode -
i extends gwt celltable create custom celltable, register sinkevents ie onmouseover/onmouseout. when hover on row of table row data populated on hover wiget(custom hover popup panel). works supose on development mode once deployed on tomcat when move mouse on different rows on celltable not update hover data on popup panel unless click away table(loose focus) , hover again on row.
public class mycelltable<t> extends celltable<t> { private tooltip popup = new tooltip(); private list<string> tooltiphiddencolumn = new arraylist<string>(); private boolean showtooltip; public mycelltable() { super(); sinkevents(event.onmouseover | event.onmouseout); } @override public void onbrowserevent2(event event) { super.onbrowserevent2(event); if (isshowtooltip()) { switch (dom.eventgettype(event)) { case event.onmouseout: { popup.hide(true); break; } case event.onmouseover: { popup.setautohideenabled(true); showtooltip(event); break; } } } } private void showtooltip(final event event) { eventtarget eventtarget = event.geteventtarget(); if (!element.is(eventtarget)) { return; } final element target = event.geteventtarget().cast(); // find cell event occurred. tablecellelement tablecell = findnearestparentcell(target); if (tablecell == null) { return; } element trelem = tablecell.getparentelement(); if (trelem == null) { return; } tablerowelement tr = tablerowelement.as(trelem); element sectionelem = tr.getparentelement(); if (sectionelem == null) { return; } tablesectionelement section = tablesectionelement.as(sectionelem); if (section == gettableheadelement()) { return; } nodelist<tablecellelement> cellelements = tr.getcells().cast(); nodelist<tablecellelement> headers = gettableheadelement().getrows().getitem(0).getcells().cast(); popup.getgrid().clear(true); popup.getgrid().resizerows(cellelements.getlength()); (int = 0; < cellelements.getlength(); i++) { if (gettooltiphiddencolumn().indexof(headers.getitem(i).getinnerhtml()) == -1) { tablecellelement tst = tablecellelement.as(cellelements.getitem(i)); popup.getgrid().sethtml(i, 0, headers.getitem(i).getinnerhtml()); popup.getgrid().sethtml(i, 1, tst.getinnerhtml()); } } // here constant values used give gap between mouse pointer , popup panel popup.setpopuppositionandshow(new popuppanel.positioncallback() { public void setposition(int offsetwidth, int offsetheight) { int left = event.getclientx() + 5; int top = event.getclienty() + 5; if ((offsetheight + top + 20) > window.getclientheight()) { top = top - offsetheight - 10; } popup.setpopupposition(left, top); } }); popup.show(); } public arraylist<reordercolumnsdetails> getcolumnsheaders(int index){ arraylist<reordercolumnsdetails> column = new arraylist<reordercolumnsdetails>(); nodelist<tablecellelement> headers = gettableheadelement().getrows().getitem(0).getcells().cast(); (int = 0; < index; i++) { reordercolumnsdetails clm = new reordercolumnsdetails(); clm.sethearder(headers.getitem(i).getinnerhtml().tostring()); clm.setitemindex(i); column.add(clm); } return column; } private tablecellelement findnearestparentcell(element elem) { while ((elem != null) && (elem != getelement())) { string tagname = elem.gettagname(); if ("td".equalsignorecase(tagname) || "th".equalsignorecase(tagname)) { return elem.cast(); } elem = elem.getparentelement(); } return null; } /** * specify name of column's not shown in tooltip */ public list<string> gettooltiphiddencolumn() { return tooltiphiddencolumn; } /** * set title tooltip * * @param title */ public void settooltiptitle(string title) { popup.sethtml(title); } public boolean isshowtooltip() { return showtooltip; } public void setshowtooltip(boolean showtooltip) { this.showtooltip = showtooltip; } }
Comments
Post a Comment