Skip to content
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

fix(ui/QTable): Use correct definition for @request's filter #14345

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/public/examples/QTable/Synchronizing.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<template>
<div class="q-pa-md">
<q-table
ref="tableRef"
title="Treats"
:rows="rows"
:columns="columns"
row-key="id"
v-model:pagination="pagination"
:loading="loading"
:filter="filter"
@request="onRequest"
binary-state-sort
@request="onRequest"
>
<template v-slot:top-right>
<q-input borderless dense debounce="300" v-model="filter" placeholder="Search">
Expand Down Expand Up @@ -90,6 +91,7 @@ const originalRows = [

export default {
setup () {
const tableRef = ref()
const rows = ref([])
const filter = ref('')
const loading = ref(false)
Expand Down Expand Up @@ -175,13 +177,11 @@ export default {

onMounted(() => {
// get initial data from server (1st page)
onRequest({
pagination: pagination.value,
filter: undefined
})
tableRef.value.requestServerInteraction()
})

return {
tableRef,
filter,
loading,
pagination,
Expand Down
53 changes: 3 additions & 50 deletions ui/src/components/table/QTable.json
Original file line number Diff line number Diff line change
Expand Up @@ -1971,56 +1971,9 @@
}
},
"filter": {
"type": "Function",
"required": true,
"desc": "Filter method (the 'filter-method' prop)",
"params": {
"rows": {
"type": "Array",
"required": true,
"desc": "Array of rows",
"__exemption": [ "examples" ]
},
"terms": {
"type": [ "String", "Object" ],
"required": true,
"desc": "Terms to filter with (is essentially the 'filter' prop value)",
"__exemption": [ "examples" ]
},
"cols": {
"type": "Array",
"desc": "Optional column definitions",
"__exemption": [ "examples" ]
},
"getCellValue": {
"type": "Function",
"desc": "Optional function to get a cell value",
"params": {
"col": {
"type": "Object",
"required": true,
"desc": "Column name from column definitions",
"__exemption": [ "examples" ]
},
"row": {
"type": "Object",
"required": true,
"desc": "The row object",
"__exemption": [ "examples" ]
}
},
"returns": {
"type": "Any",
"desc": "Parsed/Processed cell value",
"examples": [ "Ice Cream Sandwich" ]
}
}
},
"returns": {
"type": "Array",
"desc": "Filtered rows",
"__exemption": [ "examples" ]
}
"type": [ "String", "Object" ],
"desc": "String/Object to filter table with (the 'filter' prop)",
"__exemption": [ "examples" ]
},
"getCellValue": {
"type": "Function",
Expand Down
4 changes: 0 additions & 4 deletions ui/src/components/table/table-pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ export function useTablePaginationState (vm, getCellValue) {
nextTick(() => {
emit('request', {
pagination: prop.pagination || computedPagination.value,
// FIXME: 'props.filter' is string/object, but 'prop.filter' can be controlled by the user, and the docs are suggesting 'prop.filter' is a function
// So, value of 'filter' becomes function/string/object, which makes a lot of things unpredictable and can break things
// Either update the docs to say 'prop.filter' should be a string/object, or use 'prop.filter || props.filterMethod' or maybe get 'computedFilterFunction' here and use that instead of 'props.filterMethod'
// The examples on our docs are using 'filter' as a string in onRequest handler, but the JSON API is saying 'filter' is a function
filter: prop.filter || props.filter,
getCellValue
})
Expand Down