Getting sort order from external data window

J

J Kallay

Does anybody know if there's a way to iterate through the rows of a
DataRecordset in the order shown in the external data window after sorting
on one of the columns? As far as I can tell, Visio only exposes the sort
through the XML schema, not through the API.
 
A

Al Edlund

Just as a guess from the side. Each of the records in the recordset has a
number that is not associated with the key (assuming one has been
identified), and as a suspicion the external data window appears to be a
separate addin. The evidence to support this is that if you care to write
the code you can take a selection changed event and chase it to the specific
rowid in the record set. (code below). So just a standard query against the
recordset should bring back the records in their native order.
al


Private Sub ShowSelectedObjectDataRecord(visShape As Visio.Shape)
'
' this piece of code handles selecting an object and then if it
' is linked to a data recordset, open the external data window and
' select the recordset and record appropriate to the object
'
' this is a nice alternative to data graphics
'
Dim alngDataRecordsetIDs() As Long
Dim lngRowId As Long
Dim lngRecordSetId As Long
Dim winExternalData As Visio.Window
Dim visDataRecordset As Visio.DataRecordset
Dim intX As Integer

' get the list of recordset ids associated if any
visShape.GetLinkedDataRecordsetIDs alngDataRecordsetIDs

If UBound(alngDataRecordsetIDs) <> -1 Then
' take the first recordset id
lngRecordSetId = alngDataRecordsetIDs(0)
' get the associate row id
lngRowId = visShape.GetLinkedDataRow(lngRecordSetId)
Set winExternalData =
Application.ActiveWindow.Windows.ItemFromID(visWinIDExternalData)
' show the external data window
winExternalData.Visible = True
' set the linked row
Set visDataRecordset =
Application.ActiveDocument.DataRecordsets.ItemFromID(lngRecordSetId)
' move the external data window to the correct recordset
winExternalData.SelectedDataRecordset = visDataRecordset
' select the correct record
winExternalData.SelectedDataRowID = lngRowId
End If ' test for number of recordsetids associated


End Sub
 
D

David Parker

I think that you are correct.
We should ask for more properties in the next release....
 
A

Al Edlund

David,
If the recordset is read as xml (I think I sent you the code) you can see
that the records do have record ids in the schema, they're just not made
visible. That's how I use xml to go update a record if the associated custom
property has changed.
Al
 
D

David Parker

Al,

That isn't the point.
In the UI, you can Arrange By a selected column, and I think Jonathan wants
to get this column in code.
You can reset to the original order in the UI, and this is where the ID is
used.

David
 
M

Mark Nelson [MS]

A bit of clarification. The External Data Window and Visio's data
recordsets are "engine" code, not add-ins.

I can see where knowing the current sort order programmatically would be
useful. Good suggestion.

--
Mark Nelson
Office Graphics - Visio
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top