How to add button in HeaderSpan of SmartGWT

前端 未结 5 1365
轮回少年
轮回少年 2021-01-28 13:39

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

5条回答
  •  忘了有多久
    2021-01-28 14:16

    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

提交回复
热议问题