Unplanned
Last Updated: 03 Feb 2025 10:38 by John
John
Created on: 03 Feb 2025 10:38
Category: Editor
Type: Feature Request
1
Expose an Editor property to remove or set default Sort on ImageBrowser ListView Items
Currently, this can be achieved with the following solution:
        // retrieve the Editor widget object
        var editor = $("#editor").data("kendoEditor");

        // attach a click handler on the tool button, which opens the ImageBrowser dialog
        editor.toolbar.element.find(".k-i-image").parent().click(function () {
            // a setTimeout is required, otherwise the ImageBrowser widget will still not be initialized
            setTimeout(function () {
                // retrieve the ImageBrowser widget object
                var imageBrowser = $(".k-imagebrowser").data("kendoImageBrowser");
                console.log(imageBrowser);

                // retrieve the ListView widget object
                var listView = imageBrowser.listView;
                console.log(listView);

                // order the image list by directory first and then by file name
                listView.dataSource.sort({
                    field: "type", dir: "asc", compare: function (a, b) {
                        if (a.type!=b.type) {
                            return (a.type > b.type) ? 1 : -1;
                        }
                        else {
                            return a.name === b.name ? 0 : (a.name > b.name) ? 1 : -1;
                        }
                    }
                });
            });
But it would be more convenient if there is a built-in way to configure that and prevent internal sorting when not desired.
0 comments