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

Changing the ImageBrowser path according to Route parameter (MVC Wrapper)

3 Answers 174 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Maurice Thompson
Top achievements
Rank 1
Maurice Thompson asked on 23 Aug 2013, 05:25 PM
Hi,
I would like to know how I could get the ImageBrowser to use a different root folder depending upon the currently selected route.
For example, the editor within the page url  ../details/4 should open the ImageBrowser at /Content/Category/4/Images whilst the page url ../details/7 should open the ImageBrowser at /Content/Category/7/Images

Any help or suggestions would be much appreciated

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 27 Aug 2013, 02:01 PM
Hello,

You could specify a function for the read operation url and return the URL with the current page ID:

transport: {
    read: {
        url: function () {
            return "/Content/Category/" + getCurrentLocationID() + "/Images"
        },
        type: "GET"
    },
or just get the ID before initializing the widget and use it for the read configuration.

Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Maurice Thompson
Top achievements
Rank 1
answered on 18 Sep 2013, 06:42 PM
Thanks for the response but how could I do this using the MVC Wrapper?
It looks like I can only specify a route for the Read operation
0
Daniel
Telerik team
answered on 20 Sep 2013, 11:43 AM
Hello again,

When using the wrappers it should be possible to achieve this by sending the ID as route value and using custom action methods that assign the id and call the corresponding base method:

.Read("MyRead", "ImageBrowser", new { id = id })
public class ImageBrowserController : EditorImageBrowserController
{
    private int id;
 
    public override string ContentPath
    {
        get
        {
            return "~/Content/Category/" + id + "/Images";
        }
    }       
 
    public JsonResult MyRead(string path, int id)
    {
        this.id = id;
        return base.Read(path);
    }
Saving the value in the Session should be another option. Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Editor
Asked by
Maurice Thompson
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Maurice Thompson
Top achievements
Rank 1
Share this question
or