Announcement

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

    startEditingNew not working

    I've got a working ListGrid with a GWT-RPC datasource. I can fetch existing data and display it in the ListGrid without any problems. I am using the sample code from the showcase, for databound dependent-selects.

    The datasource does have a pkField with the properties set as follows:
    pkField = new DataSourceIntegerField("Id", null);
    pkField.setPrimaryKey(true);
    pkField.setCanEdit(false);
    pkField.setRequired(true);
    pkField.setRootValue(0);

    The code to add a new row is as follows:
    Code:
    addDataButton.addClickHandler(new ClickHandler() {
    	public void onClick(ClickEvent event) {
    		field1.setCanEdit(true);
    		field2.setCanEdit(true);
    		myGrid.startEditingNew();
    	}
    });
    I get the dependent-selects opened just fine.
    There are 4 columns, the first column (pkField), and the last column are not editable.

    So ... after I select an item from the first-selection, it does not go to the next drop-down combo-box.
    Code:
    field1.addChangedHandler(new com.smartgwt.client.widgets.grid.events.ChangedHandler() {
    	public void onChanged(com.smartgwt.client.widgets.grid.events.ChangedEvent event) {
                    myGrid.clearEditValue(event.getRowNum(),"dataName");
    	}
    });
    Instead, the added new record disappears.

    If I click on an existing record, this doesn't happen.

    Any help would be very much appreciated! Thanks!

    #2
    This was occuring for me as well. What I discovered is that if the cell you are trying to clear is null, (ie. as in a new record) then the new row is removed by SmartGwt when you call 'clearEditValue'.

    Adding a check in the onChanged handler to make sure the value is not null solves the problem.

    field1.addChangedHandler(new com.smartgwt.client.widgets.grid.events.ChangedHandler()
    {
    public void onChanged(com.smartgwt.client.widgets.grid.events.ChangedEvent event)
    {
    Object val = listGrid.getEditedCell( event.getRowNum(), "dataName" );
    if ( val != null )
    {
    myGrid.clearEditValue(event.getRowNum(),"dataName");
    }
    });

    Comment

    Working...
    X