Problem updating Grid via TypedList

Posts   
 
    
tomahawk
User
Posts: 169
Joined: 02-Mar-2005
# Posted on: 14-Aug-2005 22:54:18   

I have a situation where I populate a TypedList, then assign that list as the datasource to a Janus GridEX control, and all works great. The data loads into the grid control, and displays the list.

If a user wants to add a new record, they populate a form to do so, which saves their data to a new Entity, and it is saved to the DB. In order to add the newly added record to the TypedList, I requery the db with a Filter like so:

TypedListDAO dao = new TypedListDAO(); dao.GetMultiAsDataTable(MyTypedList.BuildResultset(),currentlyBoundTypedList, 0,null,PredicateFactory.CompareValue(IndividualFieldIndex.ContactID, ComparisonOperator.Equal,newID), null,false,null,null,0,0);

When I do this, the new row is added to "currentBoundTypedList" rowset properly, but the grid does not update. Does the ListChanged event not fire in this case? My understanding is that GridEX monitors the ListChanged event in order to update it's display.

Any ideas?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 15-Aug-2005 10:53:13   

It should fire indeed, at least that's my understanding too. The typedlist is a datatable which is thus bound to a grid using its defaultview, which should get a signal when the datatable is updated, but perhaps that's not happening in this case (it's .NET framework code, so I can't do a thing about it). To work around this, call Refetch on the grid after the fetch of the row took place.

Frans Bouma | Lead developer LLBLGen Pro
Rogelio
User
Posts: 221
Joined: 29-Mar-2005
# Posted on: 15-Aug-2005 13:43:17   

Hi,

All is working as must be. Your problem is that each time that you retrieve a typedlist you are creating a new instance of that typedlist and the grid was binded to the old instance. You have to rebind the new instance (reference) to the grid.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 15-Aug-2005 17:25:26   

Rogelio wrote:

Hi,

All is working as must be. Your problem is that each time that you retrieve a typedlist you are creating a new instance of that typedlist and the grid was binded to the all instance. You have to rebind the new instance (reference) to the grid.

That was what I thought at first too, but the code shows he passes a currently bound typedlist instance. If not, then indeed that's the error simple_smile

Frans Bouma | Lead developer LLBLGen Pro