ITableWindow custom selection... is it possible?

870
4
12-02-2010 02:42 PM
GregRieck
Occasional Contributor III
Hello,

Is it possible to limit the fields in a selection with ITableWindow? I'm trying to select specific data from a table and I am successful doing that. However, I'm not able to limit the results returned in the display to specific fields.

I'd like my query, "Select field1, field2, field3... From table Where..." to display on the the fields in the "Select" portion of the query in the the ITableWindow.ShowSelected = true window. Just display exactly what I want in the query without displaying the additional fields.

Of course if that wasn't enough, I'd also like to display one field from a joined table in the results. "Select table1.field1, table1.field2, table1.field3, table2.field1... From table1, table2 Where..." But first things first, if I could get it to just display the requested fields first and no other fields that would be a great leap forward.

I've tried using IQueryFilter.Subfields without success. I'm using ITableSelection, ITableWindow, and IStandaloneTableCollection. I determine if the standalone table is available in the map document, add it if not add it. NOTE: I've tried limiting the SubFields to just one table, field1, field2, field3..., without the table1. prefix without success.


QueryFilter.SubFields = "table1.field1, table1.field2, table1.field3, table2.field1";
QueryFilter.WhereClause = "WHERE..."
TableSelection.SelectionSet = Table.Select(QueryFilter, esriSelectionType.esriSelectionTypeHybrid,
 esriSelectionOption.esriSelectionOptionNormal, Workspace);
0 Kudos
4 Replies
AlexanderGray
Occasional Contributor III
I see two paths here.
You change the visible fields in the layer.  That means when you view all rows just selected rows, you will see only the fields you are interested in.  You might even find the event that switches between all rows and selected rows and apply the change to the tableview then.
Another avenue is a TableQueryName or a FeatureQueryName.  This is not a selection on your table though.  It is creating a a new table in memory based on a query or view (which can contain joined fields from another table) and add it to the map.  It would appear as an another table with only the rows and fields you want.  There is an example in the dev help under IQueryName2.  If you go that route make sure both tables are in the same workspace or else it will be slow.
0 Kudos
GregRieck
Occasional Contributor III
I see two paths here.
You change the visible fields in the layer.  That means when you view all rows just selected rows, you will see only the fields you are interested in.  You might even find the event that switches between all rows and selected rows and apply the change to the tableview then.
Another avenue is a TableQueryName or a FeatureQueryName.  This is not a selection on your table though.  It is creating a a new table in memory based on a query or view (which can contain joined fields from another table) and add it to the map.  It would appear as an another table with only the rows and fields you want.  There is an example in the dev help under IQueryName2.  If you go that route make sure both tables are in the same workspace or else it will be slow.


Thank you for the response Alexander. I've made a lot of progress but I'm having problems getting the data to display. I can get the TableQueryName table to appear with the correct fields etc.. However, the table is empty. Any thoughts?

ArcGIS10 SP1 I'm using a Personal GeoDatabase.

Greg
0 Kudos
GregRieck
Occasional Contributor III
Thank you for the response Alexander. I've made a lot of progress but I'm having problems getting the data to display. I can get the TableQueryName table to appear with the correct fields etc.. However, the table is empty. Any thoughts?

ArcGIS10 SP1 I'm using a Personal GeoDatabase.

Greg


I figured it out. I had the table window set to show selected. Once I removed that the data displayed. I like how you can give the table a name, essentially a title. However, you can't edit the data in this type of table.
I need to be able to edit the data and to add one field from another table. I'll be switching back to the visible fields approach using ITableFields and IFieldInfo3. But I can't seem to get the selection to contain the joined data. Do you have any suggestions or samples on do a selection with joined data?
Greg
0 Kudos
AlexanderGray
Occasional Contributor III
First thing is to make the join using an inmemoryrelationship class.  There are some samples on that in the dev help.  You should be able to access the joined fields through the IDisplayTable.  The IDisplayTable also contains the SelectDisplayTable method which should help you with the joined fields.
Good luck
0 Kudos