I want to add a button to the HeaderSpan of ListGrid in SmartGWT. I tried using the \'HeaderSpan.setAttribute((String property, Object value)) method but it did not work. Below
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Node;
import com.google.gwt.dom.client.NodeList;
import com.smartgwt.client.widgets.events.DrawEvent;
import com.smartgwt.client.widgets.events.DrawHandler;
import com.smartgwt.client.widgets.grid.ListGrid;
public class AdvancedListGrid extends ListGrid {
public AdvancedListGrid() {
// Create the HeaderSpan with title "Identification"
addDrawHandler(new DrawHandler(){
@Override
public void onDraw(DrawEvent event) {
insertCalendar();
}});
}
public void insertCalendar() {
for(Element element : DOMUtils.getElementsByTagName("td")) {
if(element.getInnerHTML().equals("Identification")) {
createCalendar(element);
}
}
}
public void createCalendar(Element element) {
DOMUtils.removeAllChildNodes(element);
// Create the SmartGWT calendar object. Say the object cal.
element.setInnerHTML(cal.getInnerHTML());
}
}
class DOMUtils {
public static void removeAllChildNodes(Element element) {
NodeList childList = element.getChildNodes();
for(int childIndex = 0; childIndex < childList.getLength(); childIndex++) {
element.removeChild(childList.getItem(childIndex));
}
}
public static Element[] getElementsByTagName(String tagName)
{
JavaScriptObject elements = getElementsByTagNameInternal(tagName);
int length = getArrayLength(elements);
Element[] result = new Element[length];
for (int i=0; i=0 && position