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

FileManager set default Sort and Paging?

1 Answer 260 Views
FileManager
This is a migrated thread and some comments may be shown as answers.
VnDevil
Top achievements
Rank 2
VnDevil asked on 16 May 2020, 04:24 PM

     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>

1 Answer, 1 is accepted

Sort by
0
Accepted
Aleksandar
Telerik team
answered on 19 May 2020, 03:51 PM

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.
Tags
FileManager
Asked by
VnDevil
Top achievements
Rank 2
Answers by
Aleksandar
Telerik team
Share this question
or