Announcement

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

    The edited row is disappeared from ListGrid if it has invalid data

    SmartGWT 4.1p 2014-04-28
    IE 11.0.9600.17041 (Update Versions: 11.0.7)

    Using this sample below clicking Add for a new record. Do not enter values, and select another existing row. The newly created will disappear (but come back sometimes randomly)

    Also in the case it appears, the validated line will be displayed with bigger font size.

    Please let me know if you need anything else to repeat/fix. Thanks.

    Code:
    	@Override
    	public void onModuleLoad() {
    		
    		VLayout layout = new VLayout();
    		layout.setWidth100();
    		layout.setHeight100();
    	
    		final ListGrid listGrid = new ListGrid(MovieDS.getInstance());
    		listGrid.setShowAllRecords(true);
    		listGrid.setAutoFetchData(true);
    		listGrid.setPadding(10);
    		listGrid.setWidth100();
    		listGrid.setHeight100();		
    				
    		HLayout actionLayout = new HLayout();
    		IButton addButton = new IButton("Add", new ClickHandler() {
    			
    			@Override
    			public void onClick(ClickEvent event) {
    				listGrid.startEditingNew();
    			}
    		});
    		actionLayout.setMembers(addButton);
    		
    		layout.setMembers(listGrid, actionLayout);
    		layout.draw();
    	}
    	
    	private static class MovieDS extends DataSource {  
      
            private static MovieDS instance = null;  
              
            public static MovieDS getInstance() {  
                if (instance == null) {  
                  instance = new MovieDS("movies");  
                }  
                return instance;  
            }  
      
            public MovieDS(String id) {  
                setID(id);  
                setRecordXPath("/List/movie");  
                DataSourceField titleField = new DataSourceField("title", FieldType.TEXT, "Title", 100, true);  
                DataSourceField yearField = new DataSourceField("year", FieldType.INTEGER, "Year");  
      
                setFields(titleField, yearField);  
                setDataURL("ds/movies.data.xml");  
            }  
      
        }
    ds/movies.data.xml:
    Code:
    <List>
    	<movie>
    		<title>Avatar</title>
    		<year>2009</year>
    	</movie>
    	<movie>
    		<title>Batman</title>
    		<year>1989</year>
    	</movie>
    	<movie>
    		<title>Star Wars</title>
    		<year>1977</year>
    	</movie>
    </List>

    #2
    We're not reproducing this as you describe - in our testing if you enter no values and click another row, the edit fails, leaving the empty edit row visible with a validation-failure icon.

    If you enter explicit values and click outside, or hit enter, things do go wrong - you end up with the data from the xml file being shown twice in the grid.
    This is a result of the override to the dataURL, without a call to 'setClientOnly(true)' -- essentially the dataSource attempts to save the new record by sending a request to the server data URL, and is greeted with the (static) list of entries which it assumes have all be successfully added to the data set, and so updates the grid to show them all in addition to existing data.

    In short - if you're trying to make a client-only dataSource, you'll need to mark it as such - if not, in order to support editing, you'll need a dataURL which can actually process the request and return an appropriate result for your edits.

    (Also, as an aside, this dataSource has no primaryKey field, which is pretty much a requirement for editable dataSources, so records can be uniquely identified across edits).

    Regards
    Isomorphic Software

    Comment

    Working...
    X