Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Virtual tree filter

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support
View previous topic :: View next topic  
Author Message
shashi



Joined: 05 Dec 2007
Posts: 6

PostPosted: Tue Feb 17, 2009 4:05 pm    Post subject: Virtual tree filter Reply with quote

Hi,

I am using databinding to display the rows in the virtual tree.I want to filter the rows displayed for the virtual tree, hence i am applying filter to the datasource of the virtual tree,here the datasource is of type bindingsource.

After applying filter on the datasource variable of the virtual tree that is of type binding source,i called the methods resetbindings() on the datasource variable.

Virtual tree is not able to reload the filtered data.

Code structure :

taxMasterBindingSource.Filter = _filterString; //here vtTaxMaster.datasource=taxMasterBindingSource,_filterString is some valid filter string

taxMasterBindingSource.ResetBindings(false);

vtTaxMaster.UpdateRows(true);
vtTaxMaster.Update();


Can u suggest me some way out?
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue Feb 17, 2009 10:09 pm    Post subject: Reply with quote

The BindingSource.Filter property only works if you have set the BindingSource.DataSource to a DataView (not a DataSet or DataTable). The MSDN documenation says:

Quote:
Typically used in complex data-binding scenarios, the Filter property allows you to view a subset of the DataSource. Only underlying lists that implement the IBindingListView interface support filtering.


If your BindingSource.DataSource is a DataSet or DataTable you can still filter the data - however you need to set the RowFilter on the underlying DataView instead of setting the BindingSource.Filter. For example in the Data Set Browser sample project I could filter the customers by doing the following:

Quote:
_dataSet.Customers.DefaultView.RowFilter = "CompanyName LIKE 'C*'";

_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
shashi



Joined: 05 Dec 2007
Posts: 6

PostPosted: Wed Feb 18, 2009 8:10 am    Post subject: Reply with quote

Thanks a lot ,the idea suggested by you is working.But as mentioned by you

Only underlying lists that implement the IBindingListView interface support filtering.

But BindingSource implements IBindingListView ,then y the filteration cannot be done directly on the BindingSource.

Please have a look on this.
Back to top
View user's profile Send private message
shashi



Joined: 05 Dec 2007
Posts: 6

PostPosted: Fri Feb 20, 2009 7:31 am    Post subject: Child virtual tree sort Reply with quote

Details:

MasterTable named as MTable
ChildTable named as CTable (linked to the MTable through a relation)

vtree1 has to show rows from MTable
vtree2 has to show rows from CTable(following to the parent relation)


Requirement for my desing was to have two virtual trees,where the first virtual trees shows all the rows from the MasterTable named as MTable and second virtual tree shows only the

rows that satisfiles the relation between the Master table and child table.

So, what i m doing is:

1.I have set the datasource for the first virtual tree to the dataset table MTable through a bindingsource,also as i dont want to show the child rows in the first virtual tree hence i have

removed the child property for the first virtual tree.

2.In the second virtual tree what i m doing is that i have set the datasource property to the Parent table,and as i only want to show the child rows ,i have deleted the cell bindings from

the databindings for the parent table.This step is only done to generate the appropriate databindings,when the databindigs are generated the datasource property for the second tree is

reset.

3.In the selection change event of the first tree i m setting the datasource property for the second tree by writing the code
virtualtree2.Datasource=Virtualtree1.selecteditem;



As the datasource for the first virtual tree is set to a datable the idea suggested by you is working fine for the virtual tree
that is if i m applying filter for for the datatable as
datatable.TableName.DefaultView.RowFilter = _filterString;

dsTaxPlan.MTable.DefaultView.RowFilter = _filterString;

but if i am doing the same for the second virtual tree filtering is not happening.

dsTaxPlan.CTable.DefaultView.RowFilter = _filterString;


Can u tell me a way out?
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Fri Feb 20, 2009 8:06 am    Post subject: Reply with quote

When you set the Children property to a Relation in a DataRowRowBinding Virtual Tree Data uses the DataSet Relation to get the children for the parent row. To do this it uses the DataRowView.CreateChildView method. This means it is not using the DefaultView so setting the filter on the DefaultView won't filter the children. To do this you can handle the GetChildren event for the parent DataRowRowBinding (in your case for the MTable) and set the filter on the underlying Child DataView created by the binding. The sample code below demonstrates filtering the child orders for a customer in the sample Data Set Browser project:

Code:

private void rowBindingCustomers_GetChildren(object sender, GetChildrenEventArgs e)
{
    DataViewList dvl = rowBindingCustomers.GetChildrenForRow(e.Row) as DataViewList;
    dvl.DataView.RowFilter = "Freight > 10.00";
    e.Children = dvl;   
}

_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group