How do I retrieve the ID of the current selected folder in the Report
Explorer? CurrentFolderID doesn't work since, according to the help
file, it returns "...the FolderId of the folder for the most recently
*edited* report."
Thanks in advance,
Ed Vander Hoek
Comments
Ok, I've managed to retrieve the FolderID by directly accessing the tree
view. This approach is a bit ugly, but it works. Is there a better way
of doing this?
Also, I need to programmatically add a new report to the Report
Explorer. I initially tried TppReportExplorer.New but that automatically
invokes the designer which is undesirable in this case. I'm now
attempting to use TppReportExplorer.SaveReport which works well except
that the new report isn't displayed in the list view until you move to a
different folder and then back again. Is there any way to refresh the list?
Thanks in advance,
Ed Vander Hoek
I would simply append a record in the item dataset.
HTH,
Chris Ueberall;
could access the TppReportExplorerForm.ListView.FolderID property. The
ListView is a protected property of the TppReportExplorerFrom class which
you could surface, which might be what you're looking for. There is an
example of replacing the report explorer form in the Tutorials directory of
the installation.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
TppReportExplorerForm(ppReportExplorer1.Form).Refresh;
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
Would the report list automatically update as a result of appending a
record?
Thanks for the suggestion, Jim. I tried a similar approach - I retrieved
the FolderID from the Data property of the currently selected node in
the folder tree, however your solution is a bit cleaner.
Thanks,
Ed.
This almost works. Unfortunately after doing the refresh a different
folder is displayed. For example, if I select the "Invoicing" folder,
preview a report, select the "Accounts" folder, and create a new report,
then after the refresh the "Invoicing" folder will be displayed rather
than the "Accounts" folder.
I tried using:
TReportExplorerForm(FReportExplorer.Form).ListView.FolderId := folderID;
to refresh the report list, and this /might/ be working - I'm not sure
yet. I occasionaly receive an access violation when I delete a report
and I'm not sure if that AV is caused by how I'm refreshing the list.
Are there any known issues with deleting reports?
Thanks,
Ed.
generally recommend using the report explorer visual interface to update the
folder and item end user tables. But you should be able to do it in code
since that is what we do behind the scenes. Before launching the report
explorer, can you successfully create/remove the items and folders and have
it all working when you launch the report explorer afterwards? Are you
using a custom report explorer form?
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
I haven't tried this. I can tell you that the AV error occurs in the
ComCtrls.pas file, line 6205 (Delphi 5, Update Pack 1):
procedure TTreeNode.SetImageIndex(Value: TImageIndex);
var
Item: TTVItem;
begin
FImageIndex := Value;
with Item do
begin
mask := TVIF_IMAGE or TVIF_HANDLE;
hItem := ItemId;
iImage := I_IMAGECALLBACK
else
iImage := FImageIndex;
end;
TreeView_SetItem(Handle, Item);
end;
The first Owner in the marked line is nil.
The call stack is:
TTreeNode.SetImageIndex(1)
TppReportExplorerForm.UpdateRecylceBin <--- spelling
TppReportExplorerForm.mniFileDeleteClick(...)
...
I'm using Delphi 5 Update Pack 1, Win XP, RB 7, BDE, Oracle 8i, ComCtrls
version 5.82 (xpsp1.020828-1920).
I'm using the standard form, but I'm assigning my own event handlers for
the ppmReportsNewReport, ppmReportsDesign, and spbNewReport OnClick
events. This allows me to display our own report wizard rather than the
end-user designer. I realize that I could invoke our wizard from within
the designer, but the designer is a bit intimidating for a novice end user.
Thanks for your help, Jim.
Ed.
Ok, I may have found the problem. FRecycleBinNode was pointing to an
invalid node.
This was caused by changing the parent of the form in the
TppReportExplorer's OnCreate event. This apparently (no pun intended)
causes the TTreeView to recreate its nodes. FRecycleBinNode will not be
reinitialized until UpdateTreeView is called. Since the code to delete
an item doesn't call UpdateTreeView, a AV occurs.
What I don't understand is why it only happens intermittently...
Calling TppRefportExplorerForm.Refresh seems to resolve the problem. Eg:
procedure TForm1.reportExplorerCreate(Sender: TObject);
var
frm: TppReportExplorerForm;
before: TTreeNode;
begin
frm := (reportExplorer.Form as TppReportExplorerForm);
before := frm.trvFolders.Items[0];
frm.Parent := self;
if before <> frm.trvFolders.Items[1] then ShowMessage( 'Nodes changed' );
frm.Align := alClient;
frm.BorderStyle := bsNone;
frm.BorderIcons := [];
frm.Visible := True;
frm.Refresh;
end;