Subform ile ilgili düzenleme
This commit is contained in:
parent
c947fb2a1c
commit
6766d1129d
2 changed files with 49 additions and 17 deletions
|
|
@ -82,7 +82,7 @@ define(['./workbox-a959eb95'], (function (workbox) { 'use strict';
|
|||
"revision": "3ca0b8505b4bec776b69afdba2768812"
|
||||
}, {
|
||||
"url": "/index.html",
|
||||
"revision": "0.au42u1lvc1"
|
||||
"revision": "0.agtbclbpej8"
|
||||
}], {});
|
||||
workbox.cleanupOutdatedCaches();
|
||||
workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("/index.html"), {
|
||||
|
|
|
|||
|
|
@ -136,6 +136,18 @@ const Grid = (props: GridProps) => {
|
|||
isSubForm,
|
||||
})
|
||||
|
||||
function extractSearchParamsFields(filter: any): [string, string, any][] {
|
||||
if (!Array.isArray(filter)) return []
|
||||
|
||||
// [field, op, val] formu mu?
|
||||
if (filter.length === 3 && typeof filter[0] === 'string') {
|
||||
return [filter as [string, string, any]]
|
||||
}
|
||||
|
||||
// içinde başka filter array’leri olabilir
|
||||
return filter.flatMap((f) => extractSearchParamsFields(f))
|
||||
}
|
||||
|
||||
async function getSelectedRowKeys() {
|
||||
const grd = gridRef.current?.instance
|
||||
if (!grd) {
|
||||
|
|
@ -247,20 +259,31 @@ const Grid = (props: GridProps) => {
|
|||
e.data[colFormat.fieldName] = colFormat.defaultValue
|
||||
}
|
||||
|
||||
// ExtraFilters içerisinde ilgili Field varsa, default değerleri set etme
|
||||
if (extraFilters.some((f) => f.fieldName === colFormat.fieldName)) {
|
||||
continue
|
||||
}
|
||||
|
||||
// URL'den veya Component Prop'dan gelen parametreleri set et
|
||||
if (!searchParams) {
|
||||
continue
|
||||
}
|
||||
|
||||
const filterValue = searchParams.get('filter')
|
||||
const rawFilter = searchParams?.get('filter')
|
||||
if (rawFilter) {
|
||||
const parsed = JSON.parse(rawFilter)
|
||||
const filters = extractSearchParamsFields(parsed)
|
||||
|
||||
if (filterValue) {
|
||||
if (filterValue.includes(colFormat.fieldName)) {
|
||||
const parsed = JSON.parse(filterValue) as [string, string, any]
|
||||
const [field, op, val] = parsed
|
||||
const hasFilter = filters.some(([field, op, val]) => field === colFormat.fieldName)
|
||||
|
||||
if (hasFilter) {
|
||||
const fieldMatch = filters.find(([field, op, val]) => field === colFormat.fieldName)
|
||||
|
||||
if (fieldMatch) {
|
||||
const [, , val] = fieldMatch
|
||||
|
||||
if (field === colFormat.fieldName) {
|
||||
const dType = colFormat.dataType as DataType
|
||||
|
||||
switch (dType) {
|
||||
case 'date':
|
||||
case 'datetime':
|
||||
|
|
@ -465,6 +488,8 @@ const Grid = (props: GridProps) => {
|
|||
}
|
||||
}
|
||||
|
||||
//console.log('Filter Durumu:', filter, decodeURIComponent(searchParams?.toString()))
|
||||
|
||||
gridRef.current?.instance.refresh()
|
||||
}, [extraFilters])
|
||||
|
||||
|
|
@ -684,19 +709,26 @@ const Grid = (props: GridProps) => {
|
|||
// Eğer default value varsa, bu editörü readonly yapıyoruz
|
||||
const rawFilter = searchParams?.get('filter')
|
||||
if (rawFilter) {
|
||||
const parsed = JSON.parse(rawFilter) as [
|
||||
string,
|
||||
string,
|
||||
any,
|
||||
]
|
||||
const [field, op, val] = parsed
|
||||
if (field === i.dataField) {
|
||||
const parsed = JSON.parse(rawFilter)
|
||||
const filters = extractSearchParamsFields(parsed)
|
||||
|
||||
const hasFilter = filters.some(
|
||||
([field, op, val]) => field === i.dataField,
|
||||
)
|
||||
|
||||
if (hasFilter) {
|
||||
const existsInExtra = extraFilters.some(
|
||||
(f) => f.fieldName === i.dataField && !!f.value,
|
||||
)
|
||||
|
||||
if (!existsInExtra) {
|
||||
editorOptions = {
|
||||
...editorOptions,
|
||||
readOnly: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch {}
|
||||
const fieldName = i.dataField.split(':')[0]
|
||||
const listFormField = gridDto.columnFormats.find(
|
||||
|
|
|
|||
Loading…
Reference in a new issue