(SmartGWT 1.2, the very first day+night with SmartGWT)
I need to reset selection on ListGrid. So I checked what does getSelectedState() return when nothing (no rows/records) is selected,
and I tried to pass that value to setSelectedState() when I need to reset the selection... But nothing changed.
I have noticed that the getSelectedState() method returns null even when a row is selected.
(I read somewhere that selectedState may be sensitive to whether data from DataSource has arrived already or not.
But at this moment I define the data manually, my ListGrid is not connected to any DataSource, so I assume this is not the case.)
Javadoc does not hint anything special about selectedState:
http://www.smartclient.com/smartgwt/...tedState%28%29
What am I doing wrong please?
	So far I 'reset' the selection by resetting the data.
							
						
					I need to reset selection on ListGrid. So I checked what does getSelectedState() return when nothing (no rows/records) is selected,
and I tried to pass that value to setSelectedState() when I need to reset the selection... But nothing changed.
I have noticed that the getSelectedState() method returns null even when a row is selected.
(I read somewhere that selectedState may be sensitive to whether data from DataSource has arrived already or not.
But at this moment I define the data manually, my ListGrid is not connected to any DataSource, so I assume this is not the case.)
Javadoc does not hint anything special about selectedState:
http://www.smartclient.com/smartgwt/...tedState%28%29
What am I doing wrong please?
Code:
	
	// table/grid {
ListGrid grid = new ListGrid();
grid.setShowHeaderContextMenu(false);
grid.setSelectionType(SelectionStyle.SINGLE);
// when user clicks on the grid store id of the selected service
grid.addRowMouseUpHandler(new RowMouseUpHandler()
  {
    public void onRowMouseUp(RowMouseUpEvent event)
    {
      Record selectedRecord = grid.getSelectedRecord();
      Integer serviceId = selectedRecord == null ? null : selectedRecord.getAttributeAsInt("id");
      setServiceId(serviceId);
      // let's see... {
      System.out.println(serviceId); // actually prints actual 'id' attribute (checked)
      System.out.println(grid.getSelectedState()); // _always_ null :(
      // }
    }
  });
// define fields {
TreeGridField idField = new TreeGridField("id", 25);
TreeGridField titleField = new TreeGridField("title", 150);
grid.setFields(idField, titleField);
// }
// define data {
RecordList recordList = new RecordList();
Record record;
record = Record.getOrCreateRef(JavaScriptObject.createObject());
record.setAttribute("id", 1);
record.setAttribute("title", "service A");
recordList.add(record);
record = Record.getOrCreateRef(JavaScriptObject.createObject());
record.setAttribute("id", 2);
record.setAttribute("title", "service B");
recordList.add(record);
record = Record.getOrCreateRef(JavaScriptObject.createObject());
record.setAttribute("id", 3);
record.setAttribute("title", "service C");
recordList.add(record);
grid.setData(recordList);
// }
// place the grid into GWT VerticalPanel
vPanel.add(grid);
Comment