Subform ile ilgili düzenleme

This commit is contained in:
Sedat ÖZTÜRK 2025-09-19 21:30:39 +03:00
parent c947fb2a1c
commit 6766d1129d
2 changed files with 49 additions and 17 deletions

View file

@ -82,7 +82,7 @@ define(['./workbox-a959eb95'], (function (workbox) { 'use strict';
"revision": "3ca0b8505b4bec776b69afdba2768812" "revision": "3ca0b8505b4bec776b69afdba2768812"
}, { }, {
"url": "/index.html", "url": "/index.html",
"revision": "0.au42u1lvc1" "revision": "0.agtbclbpej8"
}], {}); }], {});
workbox.cleanupOutdatedCaches(); workbox.cleanupOutdatedCaches();
workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("/index.html"), { workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("/index.html"), {

View file

@ -136,6 +136,18 @@ const Grid = (props: GridProps) => {
isSubForm, 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 arrayleri olabilir
return filter.flatMap((f) => extractSearchParamsFields(f))
}
async function getSelectedRowKeys() { async function getSelectedRowKeys() {
const grd = gridRef.current?.instance const grd = gridRef.current?.instance
if (!grd) { if (!grd) {
@ -247,20 +259,31 @@ const Grid = (props: GridProps) => {
e.data[colFormat.fieldName] = colFormat.defaultValue 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 // URL'den veya Component Prop'dan gelen parametreleri set et
if (!searchParams) { if (!searchParams) {
continue continue
} }
const filterValue = searchParams.get('filter') const rawFilter = searchParams?.get('filter')
if (rawFilter) {
const parsed = JSON.parse(rawFilter)
const filters = extractSearchParamsFields(parsed)
if (filterValue) { const hasFilter = filters.some(([field, op, val]) => field === colFormat.fieldName)
if (filterValue.includes(colFormat.fieldName)) {
const parsed = JSON.parse(filterValue) as [string, string, any] if (hasFilter) {
const [field, op, val] = parsed 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 const dType = colFormat.dataType as DataType
switch (dType) { switch (dType) {
case 'date': case 'date':
case 'datetime': case 'datetime':
@ -465,6 +488,8 @@ const Grid = (props: GridProps) => {
} }
} }
//console.log('Filter Durumu:', filter, decodeURIComponent(searchParams?.toString()))
gridRef.current?.instance.refresh() gridRef.current?.instance.refresh()
}, [extraFilters]) }, [extraFilters])
@ -684,16 +709,23 @@ const Grid = (props: GridProps) => {
// Eğer default value varsa, bu editörü readonly yapıyoruz // Eğer default value varsa, bu editörü readonly yapıyoruz
const rawFilter = searchParams?.get('filter') const rawFilter = searchParams?.get('filter')
if (rawFilter) { if (rawFilter) {
const parsed = JSON.parse(rawFilter) as [ const parsed = JSON.parse(rawFilter)
string, const filters = extractSearchParamsFields(parsed)
string,
any, const hasFilter = filters.some(
] ([field, op, val]) => field === i.dataField,
const [field, op, val] = parsed )
if (field === i.dataField) {
editorOptions = { if (hasFilter) {
...editorOptions, const existsInExtra = extraFilters.some(
readOnly: true, (f) => f.fieldName === i.dataField && !!f.value,
)
if (!existsInExtra) {
editorOptions = {
...editorOptions,
readOnly: true,
}
} }
} }
} }