Connect RadFileExplorer or RadEditor to a SQL databse

27 posts, 0 answers
  1. Telerik Admin
    Telerik Admin avatar
    1679 posts
    Member since:
    Oct 2004

    Posted 01 Dec 2009 Link to this post

    Requirements

    RadControls version ASP.NET AJAX
    .NET version 2.0
    Visual Studio version 2005 / 2008
    programming language C# / VB.NET
    browser support

    all browsers supported by RadControls


    PROJECT DESCRIPTION
    Connect RadFileExplorer or RadEditor to a SQL databse.

    If you have installed the Telerik UI for ASP.NET AJAX demos, then the Telerik.MDF database file is located in:
    INSTALL_FOLDER\Telerik\UI for ASP.NET AJAX (VERSION)\Live Demos\App_Data folder.
  2. Bob Paul
    Bob Paul avatar
    7 posts
    Member since:
    Dec 2009

    Posted 04 Dec 2009 Link to this post

    thank you very much!
  3. Lester
    Lester avatar
    13 posts
    Member since:
    May 2009

    Posted 04 Feb 2010 Link to this post

    Hello.

    Do you have some sample about using fileexplorer with webservices ?

    I am trying to connect the fileexplorer to a webservice but i am receiving the following error ( using telerik ASP.NET Ajax Q3 2009 ):

    To be XML serializable, types which inherit from ICollection must have an implementation of Add(System.String) at all levels of their inheritance hierarchy. System.Collections.Specialized.NameValueCollection does not implement Add(System.String).

    [InvalidOperationException: There was an error reflecting type 'Telerik.Web.UI.Widgets.DirectoryItem'.]
    

    This is my code inside a webservice
     
            [WebMethod] 
            public Telerik.Web.UI.Widgets.DirectoryItem GetDirectory(string _dir, string fullPath, string[] UploadPaths, string[] DeletePaths, string[] SearchPatterns, bool _includeFiles, bool _includeDirectories, bool _IsListMode, string _SelectedUrl) 
            { 
     
                    // IO.directoryinfo cant be serialized, so receive string and create the directoryinfo object here 
                    DirectoryInfo _dir = new DirectoryInfo(dir); 
     
                    PathPermissions permissions = GetPermissions(fullPath, UploadPaths,  DeletePaths); 
     
                    DirectoryItem[] subdirectories = _includeDirectories ? GetDirectories(_dir, fullPath,UploadPaths, DeletePaths,SearchPatterns ) : new DirectoryItem[] { }; 
                    FileItem[] files = _includeFiles ? GetFiles(_dir, permissions, fullPath + "/",SearchPatterns) : new FileItem[] { }; 
     
                   string tag = _IsListMode ? fullPath : string.Empty; 
                    return new DirectoryItem(_dir.name, string.Empty, fullPath, tag, permissions, files, subdirectories); 
                
            } 
     


  4. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 09 Feb 2010 Link to this post

    Hello Lester,

    The classes inside the Telerik.Web.UI.Widgets namespace cannot be returned from a web method, because they contain a field of type NameValueCollection which is not XML serializable. In your case you need to design your classes that will be return as result from the webmethods. Then you need to use the returned custom classes and instantiate the classes from Telerik.Web.UI.Widgets namespace inside the custom provider.

    I hope this helps.

    Sincerely yours,
    Fiko
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  5. Stephen Kumor
    Stephen Kumor avatar
    8 posts
    Member since:
    Mar 2010

    Posted 15 Mar 2010 Link to this post

    Hello Telerik Team,
    I love this example.  Unfortunately, I am forced to use oracle as a database.  Would you happen to have an example that uses oracle.  To go even further I need to use either a RadFileExplorer or a RadUploader to store and have the ability to view files.  This would be nice to do in a grid because I need the files to be associated to the user that submitted them and the files are hierarchical to another table within oracle.  For example, user A submits a file that associates with Row 1 in another table.  Hopefully I made myself clear.

    Thanks in advance,
    Stephen 
  6. Lini
    Admin
    Lini avatar
    2144 posts

    Posted 18 Mar 2010 Link to this post

    Hello Stephen,

    I think the database provider only uses ANSI SQL, so it is not dependent on the DBMS you are using. If you wish to use Oracle, you should simply replace System.Data.SqlClient classes in the DataServer.cs/DataServer.vb file with the ones from the Oracle Data Provider for ASP.NET. The database content provider for RadFileExplorer stores everything in a single table - no files or folders are referenced on the server's file system. To download the files in the browser, a special handler (Handler.ashx) is used. The handler queries the database and streams back the file so it is displayed in the user's browser.

    Greetings,
    Lini
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  7. Rohan
    Rohan avatar
    94 posts
    Member since:
    Jul 2012

    Posted 11 May 2012 Link to this post

    I want create custom content provider for telerik file explore  which get data from the database table . I refereed yours provided example for that , its working fine but its is got getting different levels of file and folder how can i dot this .... please help us .........
  8. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 15 May 2012 Link to this post

    Hi Rohan,

    I already answered to your post in the other forum thread on the same subject.

    http://www.telerik.com/community/forums/aspnet-ajax/file-explorer/radfileexplorer-problem-dbcontentprovider.aspx#2109388

    Greetings,
    Dobromir
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  9. Bob
    Bob avatar
    123 posts
    Member since:
    Sep 2012

    Posted 17 Jul 2013 Link to this post

    Any EntityFramework hook-in demos???
  10. Vessy
    Admin
    Vessy avatar
    1389 posts

    Posted 18 Jul 2013 Link to this post

    Hi Bob,

    If you are searching for such demos for RadFileExplorer/RadEditor, you could examine the following links:
    Editor - Custom File Dialogs Content Provider
    FileExplorer - Custom File Content Provider

    Kind regards,
    Veselina Raykova
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  11. Bob
    Bob avatar
    123 posts
    Member since:
    Sep 2012

    Posted 18 Jul 2013 Link to this post

    So, how do I use the code provided at these links?  

    I have files stored in a table with common fields (name, mime type, size, ID).  I want to pull up RadEditor and just have one Root folder for users to choose files from via Document Manager or Image Manager.  No upload, delete, edit functionality needed in Image or Document Manager.
  12. Vessy
    Admin
    Vessy avatar
    1389 posts

    Posted 22 Jul 2013 Link to this post

    Hi Bob,

    If you do not need the uses to be able to upload/delete/uplaod files, it is enough to set the ViewPaths property of the corresponding dialog. In order to see how to configure it I recommend you examine the project attached to the current Code Library.

    The format of the table, should be the same as the one this content provider is working with.  A project, containing all online demos, along with a sample database with files and folders (Telerik.mdf) is available for download here (you have to be logged into your Telerik account first).

    I hope this information will be helpful for you.

    Regards,
    Veselina Raykova
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  13. Bob
    Bob avatar
    123 posts
    Member since:
    Sep 2012

    Posted 23 Jul 2013 Link to this post

    Thanks!  I didn't really understand how the folder structure and the hierarchal Items table were set-up until looking through the Demos solution and MDF file.  All working now.
  14. Vessy
    Admin
    Vessy avatar
    1389 posts

    Posted 23 Jul 2013 Link to this post

    Hi Bob,

    I am glad to hear that the provided information served its purpose. Should you have any further questions do not hesitate to contact us again.

    Kind regards,
    Veselina Raykova
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  15. Anton
    Anton avatar
    3 posts
    Member since:
    Jan 2014

    Posted 18 Mar 2014 Link to this post

    Hi,

    I am trying to use this example, but when I delete the file the DeleteFile() function gets called with the path to the folder and not to the file I am trying to delete. When I am trying to move the file, MoveFile() function gets called with "path" pointing to the folder where the file is. The "newPath" contains fill path to the file in the new location.

    What am I missing?

    thanks.
  16. Anton
    Anton avatar
    3 posts
    Member since:
    Jan 2014

    Posted 18 Mar 2014 in reply to Anton Link to this post

    more details, 
    When I am trying to delete the file I can see the file name
    function OnClientDelete(sender, args) {
        alert("Delete file: " + args.get_item().get_name());
    }
    but on the server side parameter RadFileExplorerEventArgs e in
    FileExplorer_ItemCommand(object sender, RadFileExplorerEventArgs e) function call has only path to the folder and not to the file.
    e.Command == "DeleteFile" though.

    It seems that the control takes the item's info from the Tree view and not from the file view panel.

    thanks,


  17. Vessy
    Admin
    Vessy avatar
    1389 posts

    Posted 19 Mar 2014 Link to this post

    Hello Anton,

    I tried to reproduce this behavior with the DB provider from this article and the data base from this demo, but the full path is returned properly on my side. You can see a screenshot from my test here: image.

    Have you customized the content provider used in your project? Could you try to isolate the issue into a sample fully runnable project (including all needed references like the provider and a dummy database) and send it for a further investigation?

    Looking forward to hearing from you,
    Vessy
    Telerik
     

    DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

     
  18. Anton
    Anton avatar
    3 posts
    Member since:
    Jan 2014

    Posted 19 Mar 2014 in reply to Vessy Link to this post

    Hi Vessy,

    Thank you for the hint. I did customize your DB provider by splitting it on two parts - DataFolder and DataFile. And instead of returning FilePath to control I was returning the FolderPath.

    I corrected implementation on my side and it works now.

    Thank you.

  19. Vessy
    Admin
    Vessy avatar
    1389 posts

    Posted 20 Mar 2014 Link to this post

    Hi Anton,

    I am glad yo have managed to resolve the problem on your own. Should you need any further assistance, please, do not hesitate to contact us again.

    Regards,
    Vessy
    Telerik
     

    DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

     
  20. Boban
    Boban avatar
    4 posts
    Member since:
    Mar 2012

    Posted 25 Apr 2014 Link to this post

    I have implemented the sample code, but when I run it, and I click on ImageManager in the editor, the pop-up window comes up, but the "Upload" icon/option is disabled ... as if I don't have permissions.

    (screen-shot attached)

    What am I missing?
  21. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 28 Apr 2014 Link to this post

    Hi Boban,

    On my end I am unable to find an attached screenshot, which demonstrates the encountered problem. 

    Note, that even with a custom DB for the FileBrowser dialogs of the editor or the FileExplorer control you should properly setup the ViewPaths, DeletePaths and UploadPaths properties to allow these option for the corresponding folders to the users.

    If you still have difficulties, provide a simple project that demonstrates the implementation and the configuration of the built project, so that it could be investigated locally.

    Regards,
    Ianko
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  22. Boban
    Boban avatar
    4 posts
    Member since:
    Mar 2012

    Posted 28 Apr 2014 in reply to Ianko Link to this post

    Ianko -

    I have attached a RAR of a standalone project.  It has a simple web page with the radEditor on it, and in the codebehind I link it to the database image manager.

    The two classes that make up the database image manager were downloaded from this very page, and implemented without changes.

    Again, when I run the project, and click on the ImageManager tool, I get the dialog box, but the upload button is disabled.  The screen-shot is now in the root folder of this project file.
  23. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 29 Apr 2014 Link to this post

    Hi Boban,

    Could you verify that the table used for the content is not empty - a record with the Root element is required for the content provider to register paths correctly? For example, if paths are set to "MyDirectory" (ViewPaths = string[] {"MyDirectory/"}) a record with Name value of "MyDirectory" should be present in the table.

    Regards,
    Dobromir
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  24. Boban
    Boban avatar
    4 posts
    Member since:
    Mar 2012

    Posted 29 Apr 2014 in reply to Dobromir Link to this post

    Ok - that did the trick.  I am now able to upload content.

    The issue I'm having now is with error handling.  When I initially created the table, I created the "miletype" column too small.  As a result, the DBDataServer.AddItem function was getting an error, and simply returning it up the calling chain.

    What I don't know is how to "catch" that and display it.  The error is now showing up anywhere.  The file just didn't get uploaded, and I had to step through the code to find the problem.

    Since all of this functionality is being called directly by the editor, I don't know where to "intercept" and catch the errors so that I can display them to the user, as appropriate.

  25. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3602 posts

    Posted 02 May 2014 Link to this post

    Hello Boban,

    The try-catch in AddItem should do the trick. Perhaps you would want to remove the call to Return e.Message and return an empty string instead to avoid sending the error message onward.

    Another thing you can consider is adding try-catch blocks around the calls to AddItem.

    Ultimately, exception handling depends on the developer, the exceptions that occur and on the project. You should determine where errors originate and capture them according to your logic.


    Regards,

    Marin Bratanov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  26. Boban
    Boban avatar
    4 posts
    Member since:
    Mar 2012

    Posted 05 May 2014 in reply to Marin Bratanov Link to this post

    Marin -

    Thank you for your reply, but I don't think I asked my question correctly.

    What I'm trying to understand is how to ensure that the error is shown to the user.  With the try-catch block in place, the error is caught, but is never shown to the user.  Since I don't know the details of how this code is called, etc., I don't know where to store the error message so that it is passed back to the user.

    Right now when there is an error, it simply does nothing. 
  27. barbod
    barbod avatar
    15 posts
    Member since:
    Apr 2007

    Posted 21 Jun 2015 Link to this post

    hi

    how to add custom sql column to table and show that in FileExplorer.

    like Owner , CreateTime , ...

     

Back to Top