This is a migrated thread and some comments may be shown as answers.

Adding image column based on user control property

7 Answers 52 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Massimiliano
Top achievements
Rank 1
Massimiliano asked on 11 Apr 2014, 01:58 PM
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

7 Answers, 1 is accepted

Sort by
0
Massimiliano
Top achievements
Rank 1
answered on 12 Apr 2014, 02:22 PM
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)
0
Vessy
Telerik team
answered on 16 Apr 2014, 10:38 AM
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.

 
0
Massimiliano
Top achievements
Rank 1
answered on 16 Apr 2014, 06:46 PM
Thank you Vessy much appreciated! I will check them both and report back!
0
Massimiliano
Top achievements
Rank 1
answered on 20 Apr 2014, 12:01 PM
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?
0
Massimiliano
Top achievements
Rank 1
answered on 20 Apr 2014, 01:23 PM
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?
0
Dobromir
Telerik team
answered on 21 Apr 2014, 08:45 AM
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.

 
0
Massimiliano
Top achievements
Rank 1
answered on 03 May 2014, 12:22 PM
I've been able to test your solution only today. Sorry for the delay.
It works flawlessly! Thank you so much Dobromir!
Tags
FileExplorer
Asked by
Massimiliano
Top achievements
Rank 1
Answers by
Massimiliano
Top achievements
Rank 1
Vessy
Telerik team
Dobromir
Telerik team
Share this question
or