|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
No DataView column filtering: design weakness?data to limit the data provided to the classes that consume the data. The DataView lets you filter by row, but not by column. My data layer needs to provide two different views of of an XML data table to the user interface layer, and each different view needs to display different columns. In threads in this group I've found three solutions to this problem mentioned: duplicating the source DataTable, use SQL statements to select the correct columns, or letting the user of the DataTable or DataView (such as a DataGrid) do the filtering. Each of these solutions have problems. Duplicating the DataTable may work fine for read-only data, but it doesn't work if users will be editing different views of the data. You can't allow multiple copies of data to be edited. Using SQL statements to select different columns works fine for data that comes from a database, but my data is coming from an XML file. There is no back-end database that will provide me restricted views of my data. You can use a DataGrid's TableStyles property to filter columns, and any other grid worth using will let you filter by columns. The problem with letting the data consumer do the filtering is that the consumer should know only about the data it needs. If the data source has to rely on the data consumer to filter columns, the data source gives the consumer more information than it needs, and then it has to hope that the consumer obeys the rules and doesn't modify the columns it isn't supposed to. Out of these three solutions, it seems that the only one that will work for XML data is the third, hoping that the data consumers will not mess with columns I think they shouldn't. This isn't a great solution. Have I missed something, or did the designers of ADO.Net, by not allowing column filtering, design a system that won't let the database layer limit the view of the data consumers? Hi,
If you can hide columns in a grid it is one of the ways to handle situation. If you need to create a DataView with the specific columns, then you would need to create another DataTable, based on existing one, delete the columns you do not need and create DataView from it Show quote news:1111945291.447882.159090@o13g2000cwo.googlegroups.com... > One purpose of the DataView is to allow the classes that manage the > data to limit the data provided to the classes that consume the data. > The DataView lets you filter by row, but not by column. My data layer > needs to provide two different views of of an XML data table to the > user interface layer, and each different view needs to display > different columns. > > In threads in this group I've found three solutions to this problem > mentioned: duplicating the source DataTable, use SQL statements to > select the correct columns, or letting the user of the DataTable or > DataView (such as a DataGrid) do the filtering. Each of these solutions > have problems. > > Duplicating the DataTable may work fine for read-only data, but it > doesn't work if users will be editing different views of the data. You > can't allow multiple copies of data to be edited. > > Using SQL statements to select different columns works fine for data > that comes from a database, but my data is coming from an XML file. > There is no back-end database that will provide me restricted views of > my data. > > You can use a DataGrid's TableStyles property to filter columns, and > any other grid worth using will let you filter by columns. The problem > with letting the data consumer do the filtering is that the consumer > should know only about the data it needs. If the data source has to > rely on the data consumer to filter columns, the data source gives the > consumer more information than it needs, and then it has to hope that > the consumer obeys the rules and doesn't modify the columns it isn't > supposed to. > > Out of these three solutions, it seems that the only one that will work > for XML data is the third, hoping that the data consumers will not mess > with columns I think they shouldn't. This isn't a great solution. > > Have I missed something, or did the designers of ADO.Net, by not > allowing column filtering, design a system that won't let the database > layer limit the view of the data consumers? > Hiding columns in the grid may be the best answer, but as I mentioned
in my first post, it violates the principle of data hiding. Creating another DataTable, as I also mentioned, is a bad idea because there is no easy way to synchronize edits in the two different DataTables. I still think that failing to allow column filtering in a DataView is a design flaw. Any other thoughts? Hi,
Even if it is a design flow, you cannot delete the columns from the DataView. You also cannot have same column that belongs to two different DataTables and you will face synchronizing issue. Maybe you should create DataTable from the database using different SQL statements and synchronize data there Show quote news:1111979832.735892.203090@l41g2000cwc.googlegroups.com... > Hiding columns in the grid may be the best answer, but as I mentioned > in my first post, it violates the principle of data hiding. > > Creating another DataTable, as I also mentioned, is a bad idea because > there is no easy way to synchronize edits in the two different > DataTables. > > I still think that failing to allow column filtering in a DataView is a > design flaw. > > Any other thoughts? > |
|||||||||||||||||||||||