Skip to content

Fix filtering docs - Show Code and data source #320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@grapoza/vue-tree",
"version": "5.2.1",
"version": "5.2.2",
"description": "Tree components for Vue 3",
"author": "Gregg Rapoza <[email protected]>",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion src/stories/Examples.docs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ You can drag a node that has the `draggable` property in a node's `treeNodeSpec`

You can provide a method by which data should be filtered. Any node for which the method returns `true` or for which a subnode returns `true` will be included in the visual tree.

<a target="_blank" href="assets_data/Filtering.js">See the Model Data</a>
<a target="_blank" href="assets_data/filteringTreeViewData.js">See the Model Data</a>

<Canvas>
<Story id="examples-treeview--filtering" />
Expand Down
21 changes: 19 additions & 2 deletions src/stories/definitions/TreeView.Filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,31 @@ Filtering.args = {

const docsSourceCode = `
<template>
<tree-view :initial-model="tvModel"></tree-view>
<span>
<tree-view :initial-model="tvModel" :filter-method="filterMethod"></tree-view>
<section style="margin: 10px 0">
<input v-model="filterText" type='text' id="filter" placeholder="Filter by label text" style="margin-right: 4px" /><button @click="applyFilter">Apply Filter</button>
</section>
</span>
</template>
<script setup>
import { ref } from "vue";
import { TreeView } from "@grapoza/vue-tree";
import treeViewData from "../data/basicTreeViewData";
import treeViewData from "../data/filteringTreeViewData";

const tvModel = ref(treeViewData);
const filterText = ref("");
const filterMethod = ref(null);

const applyFilter = () => {
if (filterText.value === "") {
filterMethod.value = null;
}
else {
const lowercaseFilter = filterText.value.toLowerCase();
filterMethod.value = (n) => n.label.toLowerCase().includes(lowercaseFilter);
}
}
</script>`;

Filtering.parameters = {
Expand Down