Version: Smart GWT 3.0
browser IE 8.0
I have requirement where in I need to fill the combo box dynamically .
at present its binding data . But it is not selecting the first option as default.
This application has been built using "built-in-ds" shared by smart GWT.
I have modified the in buildinDS.java file.
package com.smartgwt.sample.client;
import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.core.KeyIdentifier;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.types.SelectionStyle;
import com.smartgwt.client.types.SortArrow;
import com.smartgwt.client.util.KeyCallback;
import com.smartgwt.client.util.Page;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.IButton;
import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.SelectItem;
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.grid.events.RecordClickEvent;
import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.VStack;
import com.smartgwt.client.widgets.viewer.DetailViewer;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class BuiltInDS implements EntryPoint {
private DynamicForm boundForm;
private DetailViewer boundViewer;
private SelectItem items;
/**
* This is the entry point method.
*/
public void onModuleLoad() {
KeyIdentifier debugKey = new KeyIdentifier();
debugKey.setCtrlKey(true);
debugKey.setKeyName("D");
Page.registerKey(debugKey, new KeyCallback() {
public void execute(String keyName) {
SC.showConsole();
}
});
ListGrid grid = new ListGrid();
grid.setWidth(130);
grid.setLeaveScrollbarGap(false);
grid.setShowSortArrow(SortArrow.NONE);
grid.setCanSort(false);
grid.setFields(new ListGridField("dsTitle", "Select a DataSource"));
grid.setData(new ListGridRecord[]{
new DSRecord("Animals", "animals"),
new DSRecord("Office Supplies", "supplyItem"),
new DSRecord("Employees", "employees")}
);
grid.setSelectionType(SelectionStyle.SINGLE);
grid.addRecordClickHandler(new RecordClickHandler() {
public void onRecordClick(RecordClickEvent event) {
DSRecord record = (DSRecord) event.getRecord();
bindComponents(record.getDsName());
}
});
// grid.draw();
items = new SelectItem();
items.setName("SelectedItems");
items.setTitle("SelectedItems");
items.setPickListWidth(210);
items.setValueField("itemName");
items.setDefaultToFirstOption(true);
items.setAllowEmptyValue(false);
items.setAutoFetchData(true);
items.setOptionDataSource(DataSource.get("supplyItem"));
HLayout layout= new HLayout();
DynamicForm form = new DynamicForm();
// form.set
items.setLeft(20);
items.setTop(75);
form.setItems(items);
layout.addMember(grid);
layout.addMember( form );
layout.setWidth(800);
layout.draw();
}
private void bindComponents(String dsName) {
DataSource ds = DataSource.get(dsName);
items.setOptionDataSource(ds);
if(dsName.equalsIgnoreCase("animals"))
items.setValueField("scientificName");
else if(dsName.equalsIgnoreCase("supplyItem"))
items.setValueField("itemName");
items.setDefaultToFirstOption(true);
let me know whats
}
}
let me know whats going wrong here.
-Vinod
Emailid: vinod.narayankar@gmail.com or vinod.narayankar@sabre.com
browser IE 8.0
I have requirement where in I need to fill the combo box dynamically .
at present its binding data . But it is not selecting the first option as default.
This application has been built using "built-in-ds" shared by smart GWT.
I have modified the in buildinDS.java file.
package com.smartgwt.sample.client;
import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.core.KeyIdentifier;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.types.SelectionStyle;
import com.smartgwt.client.types.SortArrow;
import com.smartgwt.client.util.KeyCallback;
import com.smartgwt.client.util.Page;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.IButton;
import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.SelectItem;
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.grid.events.RecordClickEvent;
import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.VStack;
import com.smartgwt.client.widgets.viewer.DetailViewer;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class BuiltInDS implements EntryPoint {
private DynamicForm boundForm;
private DetailViewer boundViewer;
private SelectItem items;
/**
* This is the entry point method.
*/
public void onModuleLoad() {
KeyIdentifier debugKey = new KeyIdentifier();
debugKey.setCtrlKey(true);
debugKey.setKeyName("D");
Page.registerKey(debugKey, new KeyCallback() {
public void execute(String keyName) {
SC.showConsole();
}
});
ListGrid grid = new ListGrid();
grid.setWidth(130);
grid.setLeaveScrollbarGap(false);
grid.setShowSortArrow(SortArrow.NONE);
grid.setCanSort(false);
grid.setFields(new ListGridField("dsTitle", "Select a DataSource"));
grid.setData(new ListGridRecord[]{
new DSRecord("Animals", "animals"),
new DSRecord("Office Supplies", "supplyItem"),
new DSRecord("Employees", "employees")}
);
grid.setSelectionType(SelectionStyle.SINGLE);
grid.addRecordClickHandler(new RecordClickHandler() {
public void onRecordClick(RecordClickEvent event) {
DSRecord record = (DSRecord) event.getRecord();
bindComponents(record.getDsName());
}
});
// grid.draw();
items = new SelectItem();
items.setName("SelectedItems");
items.setTitle("SelectedItems");
items.setPickListWidth(210);
items.setValueField("itemName");
items.setDefaultToFirstOption(true);
items.setAllowEmptyValue(false);
items.setAutoFetchData(true);
items.setOptionDataSource(DataSource.get("supplyItem"));
HLayout layout= new HLayout();
DynamicForm form = new DynamicForm();
// form.set
items.setLeft(20);
items.setTop(75);
form.setItems(items);
layout.addMember(grid);
layout.addMember( form );
layout.setWidth(800);
layout.draw();
}
private void bindComponents(String dsName) {
DataSource ds = DataSource.get(dsName);
items.setOptionDataSource(ds);
if(dsName.equalsIgnoreCase("animals"))
items.setValueField("scientificName");
else if(dsName.equalsIgnoreCase("supplyItem"))
items.setValueField("itemName");
items.setDefaultToFirstOption(true);
let me know whats
}
}
let me know whats going wrong here.
-Vinod
Emailid: vinod.narayankar@gmail.com or vinod.narayankar@sabre.com
Comment