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

[Solved] Upload In Grid Popup

0 Answers 73 Views
Upload
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Chad
Top achievements
Rank 1
Chad asked on 07 May 2011, 03:39 PM
Hello, i am using the Grid Popup Edit function using a custom EditTemplate.

Everything works fine when i upload the photo, when i click the Remove button all i get is "Remove Operation Failed - Unexpected Response From Server"

I Copied the examples line for line and im not sure what is making it behave that way !

Here is my code for the Grid:
@(Html.Telerik().Grid<MarijuanaMenuItem>()
        .HtmlAttributes(new { style = "font-size:small;" })
        .Name("MarijuanaMenu")
        .DataKeys(keys =>
            {
                keys.Add(p => p.menuid);
            })
        .ToolBar(toolbar => toolbar.Insert().ButtonType(GridButtonType.ImageAndText))
        .Columns(columns =>
        {
            columns.Bound(o => o.photo_url)
                    .Width(50)
                    .Title("Photo")
                    .ClientTemplate("<img height='50' width='50' src='http://my.potlocator.com/menu_uploads/<;#=photo_url #>' />");
            columns.Bound(o => o.description).Title("Desc").Width(150);
            columns.Bound(o => o.StrainType).Title("Type").Width(100);
            columns.Bound(o => o.StrainName).Title("Name").Width(150);
            columns.Bound(o => o.halfgram).Title("1/2g").Width(75);
            columns.Bound(o => o.gram).Title("g").Width(75);
            columns.Bound(o => o.eighth).Title("1/8").Width(75);
            columns.Bound(o => o.quarter).Title("1/4").Width(75);
            columns.Bound(o => o.half).Title("1/2").Width(75);
            columns.Bound(o => o.ounce).Title("oz").Width(75);
            columns.Bound(o => o.each).Title("ea").Width(75);
            columns.Bound(o => o.instock)
                    .ClientTemplate("<input type='checkbox' disabled='disabled' name='instock' <#= 1 ? checked='checked' : '' #> />")
                    .Title("In-Stock").Width(50);
            columns.Command(command =>
                {
                    command.Edit().ButtonType(GridButtonType.Image);
                    command.Delete().ButtonType(GridButtonType.Image);
                }).Title("Actions").Width(50);
        })
        .DataBinding(dataBinding =>
        {
            dataBinding.Ajax()
                .Select("_getMenuAjax", "Menu", new { locationid = @Model.thisListing.ListingID })
                .Update("_updateMenuAjax", "Menu")
                .Insert("_insertMenuAjax", "Menu", new { locationid = @Model.thisListing.ListingID })
                .Delete("_deleteMenuAjax", "Menu");
        })
        .Pageable()
        .Editable(editing =>
            {
                editing.Mode(GridEditMode.PopUp);
                editing.FormHtmlAttributes(new { enctype = "multipart/form-data" });
            })
        .Sortable()
        .Scrollable()
        .Groupable()
        .Filterable()
    )



Here is my code for the Upload:
@(Html.Telerik().Upload()
            .Name("file")
            .Multiple(false)
            .Async(async => async
                .Save("saveMenuPhoto", "Menu")
                .Remove("deleteMenuPhoto","Menu")
                .AutoUpload(true)
            )
            .ClientEvents(events => events
                .OnSuccess("menuUploadSuccess")
                .OnUpload("menuUpload")
            )
        )


Here is My Controller Code:

[HttpPost]
        public ActionResult deleteMenuPhoto(string fileNames)
        {
            // The parameter of the Remove action must be called "fileNames"
            //foreach (var fullName in fileNames)
            //{
            //    var fileName = Path.GetFileName(fullName);
            //    var physicalPath = Path.Combine(Server.MapPath("~/App_Data"), fileName);
 
                // TODO: Verify user permissions
            //    if (System.IO.File.Exists(physicalPath))
            //    {
                    // The files are not actually removed in this demo
                    // System.IO.File.Delete(physicalPath);
            //    }
            //}
            // Return an empty string to signify success
            return Content("");
        }
Tags
Upload
Asked by
Chad
Top achievements
Rank 1
Share this question
or