I have a 3-tiered dataset (parent, child, grandchild) on which I have
defined a dataviewmanager object (dvmData). On my form, I have set
dvmData as the datasource for a datagrid that I am using for
navigation and want to be able to filter each tier. I have tried 2
scenarios to filter each tier of the datagrid.
1) If I set a row filter via DataViewSettings, I can filter the child
and grandchild without a problem but the parent will not filter.
My code for setting the filters using DataViewSettings is:
'parent - department
strDeptFilter = "dept_code = '001'"
dvmData.DataViewSettings("Depts").RowFilter = strDeptFilter
'child - subdepartment
strSubDeptFilter = "subdept_code = '08'"
dvmData.DataViewSettings("SubDepts").RowFilter = strSubDeptFilter
'grandchild -room
strRoomFilter = "room_code = '003'"
dvmData.DataViewSettings("Rooms").RowFilter = strRoomFilter
Datagrid1.datasource = dvmData
This will filter Subdepts and Rooms correctly but the Department
filter is ignored.
2) I created a Dataview (dvDepts) from dvmData setting the parent
table as the default view. Then I set the row filter on dvDepts, and
then the datasource of the datagrid to dvDepts:
dvDepts=dvmData.DataviewSettings("Depts").table.defaultview
strDeptFilter = "dept_code = '001'"
dvDepts.RowFilter = strDeptFilter
...same filter settings for child and grandchild as above
Datagrid1.datasource = dvDepts
All the data in the datagrid still displays properly and the
Department will now filter, but of course, the child and grandchild
filters are ignored because dvmData (where the settings for their
filters are) is no longer the datasource.
The first scenario seems like it should work.... I must be missing the
point somewhere. Any suggestions are greatly appreciated!
tia,
LBC
|