Web forum is in read-only mode. Login as active registered customer for write access
  Forum Search   New Posts New Posts

Populate Treeview with a specific folder content ?

 Post Reply Post Reply
Author
Gabriel Cristea View Drop Down
New Member
New Member
Avatar

Joined: 04 Oct 2018
Posts: 12
Post Options Post Options   Quote Gabriel Cristea Quote  Post ReplyReply Direct Link To This Post Topic: Populate Treeview with a specific folder content ?
    Posted: 20 Mar 2019 at 1:34pm
Problem solved

Many thank's !
Back to Top
Bart Holvoet View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 2083
Post Options Post Options   Quote Bart Holvoet Quote  Post ReplyReply Direct Link To This Post Posted: 20 Mar 2019 at 9:23am
Please note that the OneDrive API expects a folder ID instead of a name or path.
You can use the same technique as with Google Drive by using the search function to find out a Folder's ID.

Example:
  xSky := TSkyDriveItem.Create(nil);
  TMSFMXCloudSkyDrive1.SearchList(xAppNamePublic, True, nil);
  if TMSFMXCloudSkyDrive1.Drive.Count > 0 then
    xSky := TSkyDriveItem(TMSFMXCloudSkyDrive1.Drive.Items[0]);
  TMSFMXCloudTreeViewAdapter1.Folder := xSky;

  TMSFMXCloudTreeViewAdapter1.InitMethod := TCloudAdapterInitMethod.cmFolder;
  TMSFMXCloudTreeViewAdapter1.CloudStorage := Storage;
  TMSFMXCloudTreeViewAdapter1.InitFolder(TMSFMXCloudTreeViewAdapter1.Folder);
Back to Top
Gabriel Cristea View Drop Down
New Member
New Member
Avatar

Joined: 04 Oct 2018
Posts: 12
Post Options Post Options   Quote Gabriel Cristea Quote  Post ReplyReply Direct Link To This Post Posted: 19 Mar 2019 at 6:07pm
Didn't work
I do not have AdvSkyDrive1 and TAdvTreeViewAdapter and tests with TMSFMXCloudSkyDrive1 and TMSFMXCloudTreeViewAdapter1 didn't work.

With TMSFMXCloudDropBox1, TMSFMXCloudGDrive1, and TMSFMXCloudYandexDisk1 all work ok

Here a sample of my code:
 // DropBox
  if (Sender as TTMSFMXCloudStorageFMX).ClassNameIs('TTMSFMXCloudDropBox') then
  begin
    xDrop := TDropBoxItem.Create(nil);
    xDrop.ItemType := ciFolder;
    xDrop.Path := '/' + xAppNamePublic;
    //
    TMSFMXCloudTreeViewAdapter1.Folder := xDrop;
    TMSFMXCloudTreeViewAdapter1.InitMethod := TCloudAdapterInitMethod.cmFolder;
  end;

  // GDrive
  if (Sender as TTMSFMXCloudStorageFMX).ClassNameIs('TTMSFMXCloudGDrive') then
  begin
    xGDrive := TGDriveItem.Create(nil);
    xGDrive.ItemType := ciFolder;
    if TMSFMXCloudGDrive1.SearchFolder(xAppNamePublic, true) then
      xGDrive := TGDriveItem(TMSFMXCloudGDrive1.Drive.Items[0]);
    //
    TMSFMXCloudTreeViewAdapter1.Folder := xGDrive;
    TMSFMXCloudTreeViewAdapter1.InitMethod := TCloudAdapterInitMethod.cmFolder;
  end;

  // SkyDrive
  if (Sender as TTMSFMXCloudStorageFMX).ClassNameIs('TTMSFMXCloudSkyDrive') then
  begin
    xSky := TSkyDriveItem.Create(nil);
    xSky.ItemType := ciFolder;
//    xSky.Path := '/' + xAppNamePublic;
    xSky.ID := '/' + xAppNamePublic;
    //
    TMSFMXCloudTreeViewAdapter1.Folder := xSky;
    TMSFMXCloudTreeViewAdapter1.InitMethod := TCloudAdapterInitMethod.cmFolder;
  end;

  // YandexDisk
  if (Sender as TTMSFMXCloudStorageFMX).ClassNameIs('TTMSFMXCloudYandexDisk') then
  begin
    xYandex := TYandexDiskItem.Create(nil);
    xYandex.ItemType := ciFolder;
    xYandex.Path := '/' + xAppNamePublic;
    //
    TMSFMXCloudTreeViewAdapter1.Folder := xYandex;
    TMSFMXCloudTreeViewAdapter1.InitMethod := TCloudAdapterInitMethod.cmFolder;
  end;

  //
  TMSFMXCloudTreeViewAdapter1.CloudStorage := zgCloudStorage;
Back to Top
Bart Holvoet View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 2083
Post Options Post Options   Quote Bart Holvoet Quote  Post ReplyReply Direct Link To This Post Posted: 19 Mar 2019 at 5:18pm
No problem.
Here's a more elaborate sample.
Note that you need to know the ID of the folder to be able to retrieve it's contents.

Example:
var
  si: TSkyDriveItem;
begin
  ReportMemoryLeaksOnShutdown := true;
  CloudTreeViewAdapter1.TreeView := TreeView1;

  si := TSkyDriveItem.Create(nil);
  si.ID := 'ABC123';
  AdvSkyDrive1.GetFolderList(si);
  si.Free;

You can use the TAdvTreeViewAdapter as well:
var
  si: TSkyDriveItem;
begin
  ReportMemoryLeaksOnShutdown := true;
  CloudTreeViewAdapter1.TreeView := TreeView1;

  si := TSkyDriveItem.Create(nil);
  si.ID := 'ABC123';

  CloudTreeViewAdapter1.InitFolder(si);
  si.Free;
Back to Top
Gabriel Cristea View Drop Down
New Member
New Member
Avatar

Joined: 04 Oct 2018
Posts: 12
Post Options Post Options   Quote Gabriel Cristea Quote  Post ReplyReply Direct Link To This Post Posted: 19 Mar 2019 at 4:51pm
Hi Bart,
Sorry for my begginer questions.

Can you be more specific please ?

How can i declare 'test folder' as TCloudItem, without selected it in Treeview ?

TMSFMXCloudSkyDrive1.GetFolderList('test folder');




Back to Top
Bart Holvoet View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 2083
Post Options Post Options   Quote Bart Holvoet Quote  Post ReplyReply Direct Link To This Post Posted: 19 Mar 2019 at 4:38pm
Hi,

You can use the GetFolderList call to retrieve contents of a specific folder.

Example:
  TMSFMXCloudSkyDrive1.GetFolderList(Folder: TCloudItem);
Back to Top
Gabriel Cristea View Drop Down
New Member
New Member
Avatar

Joined: 04 Oct 2018
Posts: 12
Post Options Post Options   Quote Gabriel Cristea Quote  Post ReplyReply Direct Link To This Post Posted: 19 Mar 2019 at 3:58pm
Hi,

How can i populate content of a specific folder in a Treeview with TMSFMXCloudSkyDrive1 ?

Thank you !
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down