setSort()
Beschreibung
Sortiert die Aufgaben des aktiven Projekts nach den angegebenen Parametern
Verwendung
setSort({
by?: string | ((task: object) => string),
dir?: "asc" | "desc",
tree?: boolean
}): void;
Parameter
by- (optional) das Suchkriterium (entweder der Schlüssel des Aufgaben-Attributs oder eine Suchfunktion, die einen String zurückgibt)dir- (optional) die Sortierrichtung: "asc" oder "desc"tree- (optional) aktiviert/deaktiviert die Sortierung für untergeordnete Aufgaben; standardmäßigfalse
Beispiel
const { ToDo, Toolbar } = todo;
const list = new ToDo("#root", {
tasks: [
{ id: "a", text: "A" },
{ id: "ac", text: "C", parent: "a" },
{ id: "ad", text: "D", parent: "a" },
{ id: "aa", text: "A", parent: "a" },
{ id: "ab", text: "B", parent: "a" },
{ id: "c", text: "C" },
{ id: "d", text: "D" },
{ id: "b", text: "B" },
],
});
const toolbar = new Toolbar("#toolbar", {
api: list.api,
});
// Aufgaben aufsteigend nach dem Parameter "text" sortieren
list.setSort({
by: task => task.id, // oder by: "text"
dir: "asc",
// tree: true // Baum-Sortierung aktivieren, standardmäßig false
});
Änderungsprotokoll: Hinzugefügt in v1.1
Verwandter Artikel: Aufgaben sortieren und filtern