thanks to @bramvano for the idea
thread: http://www.extjs.com/forum/showthrea...472#post369472
PHP Code:
package org.yournamehere.client.gui.components;
import com.extjs.gxt.ui.client.core.El;
import com.extjs.gxt.ui.client.core.XTemplate;
import com.extjs.gxt.ui.client.widget.grid.RowExpander;
/**
* A column config and component plugin that adds the ability for each row to be
* expanded, showing custom content that spans all the rows columns.
* with extended control over expanding rows
*
* @author anonym
*/
public class ExtendedRowExpander extends RowExpander {
/**
* Creates a new extended row expander.
*/
public ExtendedRowExpander() {
super();
}
/**
* Creates a new extended row expander with the given template.
*
* @param template the template
*/
public ExtendedRowExpander(XTemplate template) {
super(template);
}
/**
* expand all rows
*
*/
public void expandAllRows() {
for (int rowIndex = 0; rowIndex < grid.getStore().getCount(); rowIndex++) {
this.expandRow(rowIndex);
}
}
/**
* collapse all rows
*
*/
public void collapseAllRows() {
for (int rowIndex = 0; rowIndex < grid.getStore().getCount(); rowIndex++) {
this.collapseRow(rowIndex);
}
}
/**
* toggle all rows
*
* @param expand true to expand, false to collapse rows
*/
public void toggleAllRows(boolean expand) {
if (expand) {
expandAllRows();
} else {
collapseAllRows();
}
}
/**
* expand row
*
* @param rowIndex index of the row
*/
public void expandRow(int rowIndex) {
this.expandRow(getRowAsEl(rowIndex));
}
/**
* collapse row
*
* @param rowIndex index of the row
*/
public void collapseRow(int rowIndex) {
this.collapseRow(getRowAsEl(rowIndex));
}
/**
* toggle row
*
* @param rowIndex index of the row
*/
public void toggleRow(int rowIndex) {
this.toggleRow(getRowAsEl(rowIndex));
}
/**
* toggle row
*
* @param rowIndex index of the row
* @param expand true to expand, false to collapse rows
*/
public void toggleRow(int rowIndex, boolean expand) {
if (expand) {
expandRow(rowIndex);
} else {
collapseRow(rowIndex);
}
}
/**
* get the row as El
*
* @param rowIndex
* @return El row
*/
protected El getRowAsEl(int rowIndex) {
return El.fly(grid.getView().getRow(rowIndex));
}
}
usage:
PHP Code:
grid.addListener(Events.ViewReady, new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
expander.expandAllRows();
expander.collapseRow(2);
expander.collapseRow(4);
}
});