Is it possible to set ViewPath on the client, or otherwise communicate with the Image Manager from the client?

5 posts, 0 answers
  1. LeBear
    LeBear avatar
    233 posts
    Member since:
    May 2006

    Posted 18 Jul 2011 Link to this post

    I have a scenario where I'm editing the descriptions of products via an ajax-enabled UI where the user selects a product, and then edits the description for that product.  Each image has its own image gallery, which I am handling through a custom FileBrowserContent Provider in order to be able to provide access to the specific product's images while editing the description.

    I've chosen to set the ViewPaths of the editor to tell the image manager which image library to access.

    Since this is done via a completely Ajax-enabled interface, I need to be able to set the ViewPaths from the client when the user selects the product (at the same time an Ajax function is called to get the current description from the database and populate the editor with that content).

    Of course, I'm open to any other suggestions for passing the Product ID to the Image Manager if there's a better way.

    I thought of setting a session variable when the Ajax method is called, but that would interfere with the ability to have two windows open at the same time, and I'd prefer not to have that sort of limitation.

    Thank you for your assistance.
  2. LeBear
    LeBear avatar
    233 posts
    Member since:
    May 2006

    Posted 19 Jul 2011 Link to this post

    As a follow-on, is it possible to force a refresh when someone selects a folder from the image manager?

    I'm using the session variable as a workaround for now, but when I select a new product, open the editor, and then select the image gallery, I see the images for the previous product.  I hit refresh, and they update to the current product.  Can I work this so that the user isn't forced to do a refresh each time?

    BTW, I also was able to get a reference to the image gallery, but only if it has been opened once.  I used
    var MyImageManager = MyEditor.getToolByName('ImageManager');
    

    If I haven't loaded the image gallery at least once, this returns a null.  After that, it does give me a reference to an object. 

    So, assuming I can pass some information to the image manager, I want to be able to force a refresh, and now I also want to know if I can get a reference to the image manager before the user has attempted to open it once.

    Thank you.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 21 Jul 2011 Link to this post

    Hi Lebear,

    It is not possible to modify the ViewPaths / DeletePaths / UploadPaths properties client-side. RadEditor is using RadFileExplorer to provide the file browsing functionality for its dialogs. The corresponding properties of the explorer can be set only server-side (or in the markup) and the latest moment of the page lifecycle where they can be modified is the Page_Load event.

    For the described scenario I would suggest you to use the AJAX call used to populate the editor with the new data to change the value of the ViewPaths property. But you will need to do this in the Page_Load event, so to achieve this you need to check the control that initiates the AJAX request and according to it set the properties value. For your convenience I have attached a sample page demonstrating this approach.

    Please note that in order to change the ViewPaths of the ImageManager, the RadEditor should be updated during the AJAX request, thus should be inside the updatepanel, and this will solve the issue with displaying the files for the previously selected product.

    Best wishes,
    Dobromir
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  5. LeBear
    LeBear avatar
    233 posts
    Member since:
    May 2006

    Posted 21 Jul 2011 Link to this post

    Thank you for your assistance.

    Unfortunately, I do not use update panels.  I prefer to use direct Ajax calls to web services or page methods.

    For now, I will use the session to store the Product ID so that I can return the images for that product. 

    I may continue to look at this, but I need a little more information.  I don't need to actually change the ViewPath if there is some other way to set a value somewhere client-side, and then access that from the FileBrowserContent Provider.

    Is there a client-side event that fires when the image manager / file explorer opens, and is there a way to tap into this? 
    Is there any way to force a refresh every time the user selects a folder?
    When using the FileBrowserContent Provider, is there any way to access any other information about the editor or image manager, and if so, is there a way to set that on the client?

    Thank you.
  6. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 26 Jul 2011 Link to this post

    Hi Lebear,

    Yes, it is possible to access the page from within the content provider, please review the following KB article for an example:
    Get reference to the Page object inside a custom FileBrowserContentProvider

    Regarding the client-side event, you can use the OnClientCommandExecuting event and handle the ImageManager command to intercept the display of the dialog. However, because of the way RadEditor's built-in dialogs are displayed it will not be possible to force the RadFileExplorer to reload, which will be needed to reflect the changes in the session and / or any client-side modification on the page.

    In order to implement the required functionality I would recommend you to implement a custom dialog to RadEditor that will fulfill the requirements. You can find a tutorial on how to implement a custom dialog in the following live demo:
    Editor / Custom Dialogs

    All the best,
    Dobromir
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017