Hello again :) I have encountered another thing in the SelectItem class. Again, looking at your (https://www.smartclient.com/smartgwt...bobox_category) example, where you have a custom control with a "select all" button.
You use the getClientPickListData to select all rows. However, I have noticed that for larger amounts of rows in the SelectItem, that method will only return a subset of the rows, and i'm not sure it's determinable which of the rows that are selected...
I altered my testcase i gave you in the other thread to illustrate. I have a test datasource that returns 200 rows. If i click "select all" not all rows become selected, because the method does not return all rows.
Check my GWT.log output(in the checkall button clickhandler). in my case it looked like this:
So the
returns 121 rows, while
returns the correct 200 rows.
But it's different, another time it was 125, another 149... so something is strange. (using 13d pro as usual)
code:
You use the getClientPickListData to select all rows. However, I have noticed that for larger amounts of rows in the SelectItem, that method will only return a subset of the rows, and i'm not sure it's determinable which of the rows that are selected...
I altered my testcase i gave you in the other thread to illustrate. I have a test datasource that returns 200 rows. If i click "select all" not all rows become selected, because the method does not return all rows.
Check my GWT.log output(in the checkall button clickhandler). in my case it looked like this:
>>> record size: 121, recordlist: 200
getPickListData()
selectItem.getPickList().getDataAsRecordList()
But it's different, another time it was 125, another 149... so something is strange. (using 13d pro as usual)
code:
Code:
public void onModuleLoad() { Canvas.resizeControls(20); DataSource ds = new BananaDS(); final DynamicForm form = new DynamicForm(); form.setWidth(500); SelectItem multipleSelect = new SelectItem("multipleSelect"); multipleSelect.setWidth(200); multipleSelect.setPickListWidth(200); multipleSelect.setTitle("Select items"); multipleSelect.setDisplayField("name"); multipleSelect.setValueField("id"); multipleSelect.setMultiple(true); multipleSelect.setMultiple(true); multipleSelect.setOptionDataSource(ds); ToolStrip toolStrip = new ToolStrip(); toolStrip.setHeight(30); toolStrip.setWidth100(); ToolStripButton checkAllButton = new ToolStripButton(); checkAllButton.setWidth("50%"); checkAllButton.setTitle("Check"); checkAllButton.addClickHandler(event -> { SelectItem selectItem = (SelectItem) form.getField("multipleSelect"); ListGridRecord records[] = selectItem.getClientPickListData(); RecordList dataAsRecordList = selectItem.getPickList().getDataAsRecordList(); String[] values = new String[records.length]; for (int i = 0; i < records.length; i++) { values[i] = records[i].getAttributeAsString("id"); } selectItem.setValues(values); GWT.log(">>> record size: " + records.length + ", recordlist: " + dataAsRecordList.getLength()); //PickListMenu pickList = (PickListMenu) selectItem.getCanvasAutoChild("pickList"); //pickList.hide(); }); ToolStripButton checkNoneButton = new ToolStripButton(); checkNoneButton.setWidth("50%"); checkNoneButton.setTitle("Uncheck"); checkNoneButton.addClickHandler(event -> { SelectItem selectItem = (SelectItem) form.getField("multipleSelect"); selectItem.setValues(new String[0]); PickListMenu pickList = (PickListMenu) selectItem.getCanvasAutoChild("pickList"); pickList.hide(); }); toolStrip.addMember(checkAllButton); toolStrip.addMember(checkNoneButton); ListGrid pickListProperties = new ListGrid(); pickListProperties.setGridComponents(toolStrip, ListGridComponent.HEADER, ListGridComponent.BODY); multipleSelect.setPickListProperties(pickListProperties); form.setFields(multipleSelect); form.draw(); } public class BananaDS extends DataSource { public BananaDS() { setID("Banana"); DataSourceIntegerField pkField = new DataSourceIntegerField("id"); pkField.setHidden(true); pkField.setPrimaryKey(true); DataSourceTextField nameField = new DataSourceTextField("name", "Name", 128, true); DataSourceTextField descriptionField = new DataSourceTextField("desc", "Description", 2000); setFields(pkField, nameField, descriptionField); setCacheData(getRecords()); setClientOnly(true); } private Record[] getRecords(){ int amount = 200; Record[] recs = new Record[amount]; for (int i = 0; i < amount; i++) { Record record = new Record(); record.setAttribute("id", i); record.setAttribute("name", "name " + i); record.setAttribute("desc", "desc " + i); recs[i] = record; } return recs; } }
Comment