Skip to main content

set-mode

Description​

Fires when the mode type is changed

Usage​

"set-mode": ({
mode: "cards" | "table" | "panels" | "search",
}) => boolean | void;

Parameters​

The callback of the set-mode action takes an object with the following parameters:

  • mode - (required) the mode type which can be one of the following: "cards" | "table" | "panels" | "search" cards is the default value

If the callback function for this event returns false, the mode change operation will be blocked.

Example​

In the example below we block the change of the mode type:

import { Filemanager } from "@svar-ui/react-filemanager";
import { getData, getDrive } from "./common/data";

const init = (api) => {
api.intercept("set-mode", ({ mode }) => {
console.log(`New mode: ${mode}`);
return false;
});
};

<Filemanager
init={init}
data={getData()}
drive={getDrive()}
mode={"cards"}
/>

Related articles: How to access File Manager API