StrataFrame Forum

BusinessObject CurrentDataTableRefilled and BO.Sort method...

http://forum.strataframe.net/Topic4607.aspx

By Robin J Giltner - 11/17/2006

I have a small question about the Sort method on a Business Object.  On my BusinessObject's CurrentDataTableRefilled method, I call a function that populate nodes into a tree.  This function sorts the BO and then populates any child BO's and then adds the records into a tree.  The weird thing I am having happen is that when I add a new record to the BO, once I change any of the Items databound to the BO, I start getting values from other records in the databound boxes.

If I comment out the Sort method in my function called by the DataTableRefilled, I don't get these errors.  The other thing, if I put a break at this Sort call, it never stops here, like it is never getting called.  But if I put the Sort call back into the function called by the CurrentDataTableRefilled event, I start getting weirdness in the databound boxes on the form.

I tried checking for various things on the BO before the sort method, like if the BO is dirty, or if the BO is in Idle mode etc, but it seems to have no affect.

Does setting the Sort on the BO cause the BO to refresh if one of the properties changes?

Hope this makes some sense Smile

Thanks,

Robin Giltner

By Greg McGuffey - 11/17/2006

I'm just a new user myself, but I sort of ran into this myself. Try this:



- just before you change the property that is sorted on (i.e. if you are sorting on MySortField (Sort="MySortField") and you are about to change the MySortField property), check the CurrentRowIndex and some other unique field, like the PK field.

- Set the property

- Check the CurrentRowIndex and PK field.



What I've found is that the CurrentRowIndex doesn't change, but the PK does. I.e. when you update the field that is sorted on, the data table is immediately reordered, but the current row index is unchanged. The immediate reordering makes sense, because by setting the Sort property, you need to assume that it is always sorted. The CurrentRowIndex not changing is less intuitive for me, but once I got it, I could deal with it.



I used the SeekByPrimaryKey method to get back to the record I was working on.



Hope this helps!
By Robin J Giltner - 11/17/2006

Thanks Greg.  I'll give that a try, to get it working, for now in the EditingStateChanged event, I am setting the Sort to String.Empty, and in the AfterSave event, it gets resorted by the function.  This seems to be working for now, but I will try your suggestion as well.

Thanks,

Robin Giltner

By Greg McGuffey - 11/17/2006

Robin,



Your method should work well, especially if you are messing with the sort column a lot, I would think. I've been asking lots of questions, so when I saw your post and it was something that I just figured out last night(!) I thought I'd share BigGrin



Good luck!

Greg