FileManager set default Sort and Paging?

2 posts, 0 answers
  1. VnDevil
    VnDevil avatar
    60 posts
    Member since:
    Oct 2012

    Posted 16 May Link to this post

         Hi Telerik,

     

    Can I set default Sort and Paging in FileManager?
    I was try with code but It's not working:

     

    <!DOCTYPE html>
    <html>
    <head>
        <style>
            html {
                font-size: 14px;
                font-family: Arial, Helvetica, sans-serif;
            }
        </style>
        <title></title>
        <script src="https://code.jquery.com/jquery-1.12.3.min.js"></script>
    </head>
    <body>
        <div id="example">
            <div id="filemanager"></div>
     
            <script>
                $("#filemanager").kendoFileManager({
                    initialView: 'grid',
                    views: {
                        grid: {
                            // kendoGrid options
                            pageable: {
                                pageSize: 2
                            }
                        }
                    },
                    dataSource: {
                        schema: kendo.data.schemas.filemanager,
                        sort: {
                            field: 'createdUtc',
                            dir: 'desc'
                        }, // => not working
                        transport: {
                            read: {
                                url: "/kendo-ui/service/FileManager/Read",
                                method: "POST"
                            },
                            create: {
                                url: "/kendo-ui/service/FileManager/Create",
                                method: "POST"
                            },
                            update: {
                                url: "/kendo-ui/service/FileManager/Update",
                                method: "POST"
                            },
                            destroy: {
                                url: "/kendo-ui/service/FileManager/Destroy",
                                method: "POST"
                            }
                        },
                        pageSize: 2,
                        //serverPaging: true,
                    },
                    uploadUrl: "/kendo-ui/service/FileManager/Upload",
                    toolbar: {
                        items: [{
                                name: "createFolder"
                            },
                            {
                                name: "upload"
                            },
                            //{ name: "sortDirection" },
                            //{ name: "sortField" },
                            {
                                name: "changeView"
                            },
                            {
                                name: "spacer"
                            },
                            {
                                name: "details"
                            },
                            {
                                name: "search"
                            }
                        ]
                    },
                    contextMenu: {
                        items: [{
                                name: "rename"
                            },
                            {
                                name: "delete"
                            }
                        ]
                    },
                    draggable: true,
                    resizable: true
                });
     
                $(document).ready(function () {
                    var filemanager = $("#filemanager").getKendoFileManager();
     
                    filemanager.executeCommand({
                        command: "TogglePaneCommand",
                        options: {
                            type: "preview"
                        }
                    });
                    filemanager.toolbar.fileManagerDetailsToggle.switchInstance.toggle();
                })
            </script>
        </div>
    </body>
    </html>
  2. Aleksandar
    Admin
    Aleksandar avatar
    83 posts

    Posted 19 May Link to this post

    Hello,

    The FileManager can sort by two criteria at maximum. You can customize them by extending the defaultSortOption and the folderSortOption, as demonstrated in this dojo. This way you can set the default sort options for the Filemanager.

    $.extend(filemanager.defaultSortOption, {
                field:"createdUtc", 
                dir:"desc"
              });
    
    $.extend(filemanager.folderSortOption, {
                field:"createdUtc", 
                dir:"desc"
              });

     

    You can also configure the paging for the grid view, as demonstrated in the above-linked dojo:

     

    $("#filemanager").kendoFileManager({
              views: {
                        grid: {
                            pageable: {
                                pageSize: 3
                            }
                        }
                    },
              dataSource: {
                schema: kendo.data.schemas.filemanager,
                transport: {
    ...
                },
                pageSize:3
              },

     

    Let me know if you have additional questions.

    Regards,
    Aleksandar
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
Back to Top