Announcement

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

    ListGrid inserting problem

    Hi,

    i have the following problem:

    i need to insert a record into a ListGrid at a specific position:
    like this:
    Code:
    insert( Record r, index i )
    since the api only provides an addData i tried to work around it by adding an entry at the end and rewriting the attributes of all records between my index and the newly created one at the end.
    It works fine but after selecting something inserted elements are copies of some already existing elements! I must have missed something important ;-(

    Code:
    public void insert(ModelElement element, int index) {
    	ListGridRecord record = createRecord(element);
    	ListGridRecord placeholder = new ListGridRecord();
    	widget.addData( placeholder );
    	ListGridRecord[] records = widget.getRecords();
    	for ( int i = records.length - 1; i > index; i-- ) {
    		copyRecordInformation( records[ i - 1 ], records[ i ] );
    	}
    	copyRecordInformation( record, widget.getRecords()[ index ] );
    	widget.redraw();
    }
    Can anybody tell me what i missed?

    Or can anybody recommend a better solution?

    greetings,
    crimson

    #2
    Is the grid sorted? How about adding the record such that it sorts to the right place?

    If that's not appropriate, you would need to explain more about the order you are trying to establish, how long it's intended to last, and why this particular approach as opposed to using the automatic cache sync features.

    Comment


      #3
      well.. it is not sorted

      but thinking about the possibility to sort the widget itself i realize that it makes no sense at all trying to insert at a specific position into the widget

      => problem solved - i wont insert anything

      thanks,
      crimson

      Comment

      Working...
      X