I am using a grid which has expanding rows and grid cell widgets.
My problem is when i am expanding the row the button widget is moving to the expanded row and when i close the expanded row the button is coming back.
Can someone please let me know how to put the button in fixed position on row instead of moving to expanded row.
I am using smartgwt EE.
Please see the attached images for clarity.
Thanks
My problem is when i am expanding the row the button widget is moving to the expanded row and when i close the expanded row the button is coming back.
Can someone please let me know how to put the button in fixed position on row instead of moving to expanded row.
I am using smartgwt EE.
Code:
import com.google.gwt.core.client.EntryPoint; import com.google.gwt.user.client.ui.Label; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.data.DataSourceField; import com.smartgwt.client.data.fields.DataSourceIntegerField; import com.smartgwt.client.data.fields.DataSourceTextField; import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.grid.ListGridRecord; import com.smartgwt.client.widgets.layout.VLayout; public class HelloWorld implements EntryPoint { public void onModuleLoad() { SC.showConsole(); final ListGrid listGrid = new ListGrid() { @Override protected Canvas createRecordComponent(ListGridRecord record, Integer colNum) { String fieldName = getFieldName(colNum); if (fieldName.equals("info")) { return new IButton("Info"); } return null; } @Override protected Canvas getExpansionComponent(final ListGridRecord record) { VLayout layout = new VLayout(5); layout.setPadding(5); Label l = new Label("Expanded row"); layout.addMember(l); return layout; } }; listGrid.setWidth(500); listGrid.setHeight(300); ListGridField lastname = new ListGridField("lastname", "Last Name"); ListGridField firstname = new ListGridField("firstname", "First Name"); ListGridField mi = new ListGridField("mi", "MI"); ListGridField info = new ListGridField("info", "Info"); listGrid.setFields(lastname, firstname, mi, info); listGrid.setShowRecordComponents(true); listGrid.setShowRecordComponentsByCell(true); listGrid.setCanExpandRecords(true); TestDataSource ds = new TestDataSource(); listGrid.setDataSource(ds); listGrid.fetchData(); listGrid.draw(); } public class TestDataSource extends DataSource { public TestDataSource() { setClientOnly(true); DataSourceField pk = new DataSourceIntegerField("id"); pk.setHidden(true); pk.setPrimaryKey(true); addField(pk); DataSourceField field = new DataSourceTextField("lastname"); addField(field); field = new DataSourceTextField("firstname"); addField(field); field = new DataSourceTextField("mi"); addField(field); createRecord(1, "Smith", "John", "A"); createRecord(2, "Smith", "Dave", "B"); createRecord(3, "Smith", "Pat", "C"); createRecord(4, "Jones", "Jim", "D"); createRecord(5, "Jones", "Mary", "E"); createRecord(6, "Johnson", "Paul", "F"); createRecord(7, "Brown", "Ed", "G"); } private void createRecord(int id, String last, String first, String mi) { ListGridRecord record = new ListGridRecord(); record.setAttribute("pk", id); record.setAttribute("lastname", last); record.setAttribute("firstname", first); record.setAttribute("mi", mi); addData(record); } } }
Thanks
Comment