I am aware of the option Chris suggested, but it is a bit too rough for my taste, I need to expand only the items that was expanded before the filter.
What I am working on is this global function which works for one level :
global type f_filter_treeview from function_object
end type
forward prototypes
global subroutine f_filter_treeview (datawindow adw, string as_filter)
end prototypes
global subroutine f_filter_treeview (datawindow adw, string as_filter);long ll_rowid[], ll_row, ll_row2
for ll_row = 1 to adw.rowcount()
if adw.isexpanded( ll_row, 1) then ll_rowid[upperbound(ll_rowid) + 1] = adw.getrowidfromrow( ll_row)
next
adw.setredraw(false)
adw.setfilter(as_filter)
adw.filter()
for ll_row = 1 to upperbound(ll_rowid)
ll_row2 = adw.getrowfromrowid( ll_rowid[ll_row])
if ll_row2 > 0 then
adw.expand(ll_row2 , 1)
end if
next
adw.setredraw(true)
end subroutine