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

ImageBrowser - delete directory not working?

2 Answers 98 Views
Editor
This is a migrated thread and some comments may be shown as answers.
JohnVS
Top achievements
Rank 1
JohnVS asked on 02 May 2014, 08:52 PM
Our Editor, with ImageBrowser, code is like so:

$("#Html").kendoEditor({
    encoded: false,
    imageBrowser: {
        schema: {
            model: {
                id: "EntFileId",
                fields: {
                    name: "name",
                    type: "type",
                    size: "size",
                    EntFileId: "EntFileId"
                }
            }
        },
        transport: {
            read: "@Url.Action("Index", "EditorImageBrowser", new { area = "" })",
            destroy: {
                url: "@Url.Action("Delete", "EditorImageBrowser", new { area = "" })",
                type: "POST"
            },
            create: {
                url: "@Url.Action("Create", "EditorImageBrowser", new { area = "" })",
                type: "POST"
            },
            thumbnailUrl: function (path, name) {
                var entFileId = "";
                var data = $(".k-imagebrowser").data("kendoImageBrowser").dataSource.data();
                $.each(data, function (key, obj) {
                    if (obj.name == decodeURI(name))
                        entFileId = obj.EntFileId;
                });
                var ext = name.substring(name.lastIndexOf("."));
                var url = "@Model.BlobPath" + entFileId + "/thumb" + ext;
                return url;
            },
            uploadUrl: "@Url.Action("Upload", "EditorImageBrowser", new { area = "" })",
            imageUrl: function (name) {
                //get only filename
                if (name.indexOf('/') !== -1) {
                    name = name.substring((name.lastIndexOf("/") + 1));
                }
 
                var entFileId = "";
                var data = $(".k-imagebrowser").data("kendoImageBrowser").dataSource.data();
                $.each(data, function (key, obj) {
                    if (obj.name == decodeURI(name))
                        entFileId = obj.EntFileId;
                });
                var url = "@Model.BlobPath" + entFileId + "/" + name;
                return url;
            }
        }
    },
    tools: [
        "clear", "bold", "italic", "underline", "strikethrough", "justifyleft", "justifycenter", "justifyRight", "justifyFull",
        "insertUnorderedList", "insertOrderedList", "indent", "outdent",
        "createLink", "unlink", "insertImage", "createTable", "addColumnLeft", "addColumnRight", "addRowAbove", "addRowBelow", "deleteRow", "deleteColumn",
        "viewHtml", "formatting", "fontName", "fontSize", "foreColor", "backColor"
    ]
});

Everything is working great, except when I click on a Directory in the ImageBrowser and click the Delete button. When I click the Delete button, the alert pops up asking if I want to delete the directory . When I click OK, the directory disappears from the ImageBrowser, but a call to the server is never made. No errors appear in the console of Developer Tools in Chrome 34 or IE11.

I should note that deleting individual images works fine. It's only deleting directories that doesn't currently work.

I notice that the demo on demos.telerik.com does work with deleting directories, so it has got to be a problem with our code. But what from my code above could be causing this issue? Why are no errors appearing in the console? Any tips, advice, or thoughts of possible things that could be wrong are appreciated. Thank you for your time.

2 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 05 May 2014, 07:02 AM
Hello John,

Are you deleting directories that have been created on the client-side? If the Create action does not return an ID, the directories are considered as not existing on the server, and the Destroy action will not post to the server. If that is not the case (i.e. if the Create action returns a proper result), please provide a project that reproduces the problem. There is also a reference implementation for the ImageBrowser service that is available in the UI for ASP.NET examples.

Regards,
Alex Gyoshev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
JohnVS
Top achievements
Rank 1
answered on 05 May 2014, 01:33 PM
I checked the directory item's ID and noticed that it was blank. I ended up just needing to remove the id: "EntFileId" designation in our code, since it wasn't necessary in this case, and that did fix the problem. So the lesson learned here is that if the ID of an item isn't set, it can silently break stuff. Thanks for the tip, Alex.
Tags
Editor
Asked by
JohnVS
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
JohnVS
Top achievements
Rank 1
Share this question
or