Announcement

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

    RecordList remove throws Error

    Hello:

    I'm having a problem using RecordList (latest build from 9/21/09.

    When I call the RecordList.remove method I'm getting the following error;

    Uncaught JavaScript exception [com.google.gwt.core.client.JavaScriptException: (TypeError): Object doesn't support this property or method
    number: -2146827850
    description: Object doesn't support this property or method
    at com.smartgwt.client.data.RecordList.removeAt(Native Method)


    Here's my code:

    Code:
    RecordList rl = _parentList.getRecordList();
    					
    int index = rl.findIndex("id",_currentRecord.getAttributeAsInt("id"));
    					
    if(index != -1)
    {
    	Record r = rl.removeAt(index);  //This line throws the error
    												
    	r.setAttribute("lastname", (String)_lastName.getValue());
    	r.setAttribute("firstname", (String)_firstName.getValue());
    
    	rl.addAt(r,index);
    }
    Ultimately I'm looking for a way to update a record in the list. If there's a better and supported way please let me know.

    thanks!

    Chris

    #2
    Hi Chris,
    I was able to reproduce the issue. This issue is with removeAt(..) and it needs to be fixed.

    However there's a simpler way to do this. Simply call grid.updateData(record) after updating the attributes of the record in question. Your DataSource needs to have a PK defined.

    Sanjiv

    Comment


      #3
      Error in removeAt

      I am having the same problem of removing and in addAt, I would put a specific record always on top of the list, and other records remain ordered, any solution?

      Code:
      if (getCategoryGrid().getRecordList() != null && !getCategoryGrid().getRecordList().isEmpty()) {
      
      	int index = getCategoryGrid().getRecordList().findIndex(CategoryAttrib.ID_CATEGORIA, 1);
      
      	RecordList list = getCategoryGrid().getRecordList();
      
      	if (index > 0) {
      		Record record = list.get(index);
      		if (record != null) {
      			getCategoryGrid().getRecordList().removeAt(index);
      			getCategoryGrid().getRecordList().addAt(record, 0);
      		}
      	}
      
      }

      Comment

      Working...
      X