मैंने इसी समस्या को हल करने के लिए एक अलग दृष्टिकोण लिया।
मूल अवधारणा किसी ईवेंट के आधार पर पंक्तियों को जोड़ने और निकालने के लिए डोम तत्वों का उपयोग कर रही है। निम्नलिखित कोड सेलटेबल का एक सार विस्तार है। आप इस विधि को अपने ईवेंट से कॉल करना चाहते हैं जो एक पंक्ति का विस्तार करने के लिए क्लिक से निकाल दिया जाता है।
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NodeList;
public abstract class ActionCellTable<T> extends CellTable<T> {
protected abstract void addActionsColumn();
Integer previousSelectedRow = null;
public void displayRowDetail(int selectedRow, Element e){
//Get the tbody of the Cell Table
//Assumption that we want the first (only?) tbody.
Element tbody = this.getElement().getElementsByTagName("tbody").getItem(0);
//Get all the trs in the body
NodeList<Element> trs = tbody.getElementsByTagName("tr");
//remove previously selected view, if there was one
if(previousSelectedRow!=null){
trs.getItem(previousSelectedRow+1).removeFromParent();
//If the current is further down the list then the current your index will be one off.
if(selectedRow>previousSelectedRow)selectedRow--;
}
if(previousSelectedRow==null || selectedRow != previousSelectedRow){// if the are equal we don't want to do anything else
Element td = Document.get().createTDElement();
td.setAttribute("colspan", Integer.toString(trs.getItem(selectedRow).getChildNodes().getLength()));
td.appendChild(e);
Element tr = Document.get().createTRElement();
tr.appendChild(td);
tbody.insertAfter(tr, trs.getItem(selectedRow));
previousSelectedRow=selectedRow;
} else {
previousSelectedRow=null;
}
}
}
previousSelectedRow ट्रैक करने के लिए जो आइटम "विस्तार" है, यह शायद वर्ग या आईडी का उपयोग प्राप्त किया जा सकता प्रयोग किया जाता है। यदि आवश्यक हो तो मैं सेलटेबल, घटनाओं, विचारों और गतिविधियों पर और विस्तार कर सकता हूं।
जानना अच्छा है, धन्यवाद! मैं अभी भी 2.4 के समाधान पर काम कर रहा हूं (सीएसएस जादू + विस्तार से तालिका ऊंचाई को मैन्युअल रूप से अपडेट कर रहा हूं)। – alexandroid