Announcement

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

    Bug: ListGrid::removeSelectedData() results in a fetch-operation

    Hello,

    if the following 3 conditions apply, a fetch operation is triggered instead of a remove operation:
    1. use RestDataSource with JSON format
    2. set a custom operationId for remove request
    3. call ListGrid::removeSelectedData()

    here is a TestCase for reproducing the behaviour:

    (SmartGWT 3.1p LGPL 2012/11/30)

    Code:
    	@Override
    	public void onModuleLoad() {
    		final ListGrid lg = new ListGrid();
    		RestDataSource ds = new RestDataSource();
    		[b]ds.setDataFormat(DSDataFormat.JSON);[/b]
    
    		DataSourceField pk = new DataSourceField("pk", FieldType.TEXT);
    		pk.setPrimaryKey(true);
    		ds.setFields(pk, new DataSourceField("foo", FieldType.TEXT));
    		ds.setCacheAllData(true);
    		ds.setCacheData(new Record() {{
    			setAttribute("pk", "1");
    			setAttribute("foo", "bar");
    		}});
    
    		lg.setDataSource(ds);
    [b]		lg.setRemoveOperation("myRemove");[/b]
    		lg.setCanRemoveRecords(true);
    
    		ToolStrip strip = new ToolStrip();
    		final ToolStripButton remove = new ToolStripButton("remove");
    		remove.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
    			@Override
    			public void onClick(ClickEvent event) {
    [b]				lg.removeSelectedData();[/b]
    			}
    		});
    		strip.addButton(remove);
    		lg.setGridComponents(ListGridComponent.HEADER, ListGridComponent.BODY, strip);
    
    		lg.fetchData(new Criteria("pk", "1"));
    
    		lg.draw();
    	}

    #2
    We've made a change that should prevent this possibility - please retest with a build of 12/02 or later

    Comment


      #3
      Hello,

      the bug still exists, if you set a FetchOperation with the same Id as the RemoveOperation:

      Code:
      		lg.setFetchOperation("foo");
      		lg.setRemoveOperation("foo");

      Comment


        #4
        That's incorrect usage - operationIds are unique per DS, irrespective of type.

        Comment


          #5
          that's unfortunate ... So I have to do a workaround. Is there a possibility to pass global parameters to every reqest of a specific DataSource, no matter of the OperationType?

          Comment

          Working...
          X