Adding image column based on user control property

8 posts, 0 answers
  1. Massimiliano
    Massimiliano avatar
    184 posts
    Member since:
    Oct 2012

    Posted 11 Apr 2014 Link to this post

    Hallo I saw the example at
    http://demos.telerik.com/aspnet-ajax/fileexplorer/examples/applicationscenarios/customgridcolumns/defaultvb.aspx?#qsf-demo-source
    And I also read some other topics and stuff in the control reference but still I didn't come up with an idea on how to solve this.
    I use the explorer to upload images (for news, profiles, whatever) and I need to make one of all the uploaded images as the "main one".
    I handled all the logic for this but now I would like to display a little image in the file explorer grid near the "main image" so that users can see at a glance which one is the "main image".
    So I need to add a column to the grid which will show that image only if the filename is equal to the "main image file name, which I keep in my page/usercontrol property (hidden input field or whatever).
    So mangling with the file provider is not useful in my situation since I have to match the file name with a variable which is not accessible inside the file provider (I guess).

    Any hint?

    Thanks in advance
  2. Massimiliano
    Massimiliano avatar
    184 posts
    Member since:
    Oct 2012

    Posted 12 Apr 2014 in reply to Massimiliano Link to this post

    Instead of adding a column, another option would be to add that icon in the filename column (both before or after the filename).
    Anyway in both scenario I would have to hook in the grid databound/itemcreated event I guess, since in the file provider I cannot access the data I need to decide if the icon has to be shown or not (the data is in a hidden field or property in the page/control containing FileExplorer)
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Vessy
    Admin
    Vessy avatar
    1380 posts

    Posted 16 Apr 2014 Link to this post

    Hello Massimiliano,

    You could achieve both of the described scenarios, but still both of the approaches require a custom content provider implementation:

    I hope this information will be helpful for you.


    Regards,
    Vessy
    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.

     
  5. Massimiliano
    Massimiliano avatar
    184 posts
    Member since:
    Oct 2012

    Posted 16 Apr 2014 in reply to Vessy Link to this post

    Thank you Vessy much appreciated! I will check them both and report back!
  6. Massimiliano
    Massimiliano avatar
    184 posts
    Member since:
    Oct 2012

    Posted 20 Apr 2014 Link to this post

    I went for the first solution which is quite straightforward. I got a reference to the host page inside the FileSystemContentProvider but the problem is that the field is inside the User Control where the actual File Explorer is.
    Here is the chain: Master Page > Page > User Control > FileExplorer + Hidden Field
    I tryed to use FindControl in the Page that I get with the handler, to get a reference to my User Control but it seems that at that stage the User Control is not yet instantiated. Debugging the whole thing, the Page retrieved in the provider has 5 controls in it but only the first is instantiated (which is the master page) the other 4 controls (including my User Control which hosts the FileExplorer + HiddenField) are still Nothing at that stage.

    Any hint?
  7. Massimiliano
    Massimiliano avatar
    184 posts
    Member since:
    Oct 2012

    Posted 20 Apr 2014 in reply to Massimiliano Link to this post

    Since FileExplorer uses radgrid to display files wouldn't it be easier to attach to the grid events of the FileExplorer like RadGrid.ItemDataBound or RadGrid.ItemCreated or such?
  8. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 21 Apr 2014 Link to this post

    Hi Massimiliano,

    In such scenario, you need to go through the whole chain, i.e.:
    (HttpContext.Current.Handler as Page).Master.FindControl("ContentPlaceHolder1").FindControl("uc1").FindControl("hidden1").

    Regarding RadGrid events, the grid used in the RadFileExplorer is databound on the client and the server-side events are not fired.

    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.

     
  9. Massimiliano
    Massimiliano avatar
    184 posts
    Member since:
    Oct 2012

    Posted 03 May 2014 in reply to Dobromir Link to this post

    I've been able to test your solution only today. Sorry for the delay.
    It works flawlessly! Thank you so much Dobromir!
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017