Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    ListGrid not honoring single selection on record collapse

    sgwt: 5.0p
    sc: v10.0p_2014-11-30
    ff 26

    Multiple records (up to 3) are remaining selected on the list grid.
    To reproduce: click the record expansion icon of a record then click the record expansion icon of another record. Repeat as necessary.

    Code:
    public void onModuleLoad() {
           new ListGrid() {
    		private DynamicForm form;
    	    	@Override
    	    	protected Canvas getExpansionComponent(final ListGridRecord record) {
    	    		return new VLayout(4) {{
    	    			form = new DynamicForm() {{
    	    				setDataSource(new ClientOnlyDataSource(new Record[]{record}, new DataSourceTextField("id"){{
    							setPrimaryKey(true);
    					}}));
    	    			}};
    		    		form.editRecord(record);
    		    		addMember(form);
    	    		}};
    	    	}
        		{
        			setWidth100();
        			setHeight100();
        			setCanExpandRecords(true);
        			setCanExpandMultipleRecords(false);
        			addRecordCollapseHandler(new RecordCollapseHandler() {
    				@Override
    				public void onRecordCollapse(RecordCollapseEvent event) {
    					Record record = event.getRecord();
    					Record record0 = form.getValuesAsRecord();
    					List<String> properties = new ArrayList<String>(Arrays.asList(record0.getAttributes()));
    					Record.copyAttributesInto(record, record0, properties.toArray(new String[properties.size()]));
    				}
    			});
        			setFields(new ListGridField("id"));
    			ListGridRecord[] records = new ListGridRecord[5];
        			for (int i = 0; i < 5; ++i) {
        				records[i] = new ListGridRecord();
        				records[i].setAttribute("id", i);
        			};
        			setData(records);
        		}
    	}.show();
    }

    Thank you.

    #2
    We're looking into this and will update here when we have more info

    Comment


      #3
      Can you explain what you're trying to achieve with the code in your RecordCollapseHandler()? It's that code, which combines properties in some way, that's causing the behavior you're getting, as you can see if you comment it out.

      Comment


        #4
        Right. It looks like the Record.copyAttributesInt() and possibly when form.editRecord() is called is causing this behavior.

        I didn't write this specific code, but it looks like on record collapse the event record doesn't see form changes so we pull the attributes from the form to copy into the record. And this record has data that the form doesn't know about.

        Comment


          #5
          any update or suggestions on this?

          Comment

          Working...
          X