View Single Post
  #4  
Old 07-12-2007, 07:10 AM
zargron's Avatar
zargron zargron is online now
Registered User
 
Join Date: 05-16-2007
Location: Grassy Knoll
Posts: 149
Re: Re: Maintain position in search results when deleting items

Quote:
Originally posted by quant
this is not as easy as it might look, cause by deleting an item, you could delete the one that preceded it, or followed ... or many more ... if they were down the tree of the deleted item.
A bit of effort but not that hard.

Usually, when we delete an entry in the middle of a flat list, the lower entries move up one row and focus shifts to the entry that was just below the deleted one.

Before delete, we have search result (A) associated with an indexed array

User deletes item

Re-run query to produce search result (B)

Focus closest next entry...
Iterate down indexed array (A), starting from the item that was just below the deleted item, looking for a match in search result (B), then focus that item. When finished, free indexed array (A). If matching item not found, simply leave the first item in search result (B) focussed.
Reply With Quote