Grid Extra Filters
This commit is contained in:
parent
b394c8d837
commit
656d162617
6 changed files with 53 additions and 35 deletions
|
|
@ -13431,8 +13431,8 @@
|
|||
{
|
||||
"resourceName": "Platform",
|
||||
"key": "ListForms.ListFormEdit.SelectionMode",
|
||||
"en": "Auto Expand All",
|
||||
"tr": "Mod"
|
||||
"en": "Selection Mode",
|
||||
"tr": "Seçim Modu"
|
||||
},
|
||||
{
|
||||
"resourceName": "Platform",
|
||||
|
|
|
|||
|
|
@ -82,7 +82,13 @@ const useListFormCustomDataSource = ({
|
|||
}
|
||||
}
|
||||
}
|
||||
parameters.filter = JSON.stringify(combinedFilter)
|
||||
|
||||
if (combinedFilter && combinedFilter.length > 0) {
|
||||
parameters.filter = JSON.stringify(combinedFilter)
|
||||
} else {
|
||||
delete parameters.filter // hiç göndermesin
|
||||
}
|
||||
|
||||
//parameters.filter = JSON.stringify(parameters.filter)
|
||||
const response = await dynamicFetch('list-form-select/select', 'GET', parameters)
|
||||
|
||||
|
|
@ -164,18 +170,25 @@ const useListFormCustomDataSource = ({
|
|||
group: '',
|
||||
})
|
||||
|
||||
// 1. Default filter'ı al
|
||||
const defaultFilter = searchParams?.get('filter')
|
||||
? JSON.parse(searchParams.get('filter')!)
|
||||
: null
|
||||
|
||||
let combinedFilter: any = parameters.filter
|
||||
|
||||
// 2. Eğer hem default hem de grid filter varsa merge et
|
||||
if (defaultFilter && combinedFilter) {
|
||||
combinedFilter = [defaultFilter, 'and', combinedFilter]
|
||||
} else if (defaultFilter) {
|
||||
combinedFilter = defaultFilter
|
||||
}
|
||||
|
||||
parameters.filter = JSON.stringify(combinedFilter)
|
||||
if (combinedFilter && combinedFilter.length > 0) {
|
||||
parameters.filter = JSON.stringify(combinedFilter)
|
||||
} else {
|
||||
delete parameters.filter // hiç göndermesin
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await dynamicFetch('list-form-select/select', 'GET', parameters)
|
||||
|
|
@ -193,28 +206,29 @@ const useListFormCustomDataSource = ({
|
|||
return null
|
||||
}
|
||||
},
|
||||
byKey: async (key) => {
|
||||
const parameters = getLoadOptions(
|
||||
{ key },
|
||||
{ listFormCode, filter: '', createDeleteQuery: '' },
|
||||
)
|
||||
parameters.filter = JSON.stringify(parameters.filter)
|
||||
try {
|
||||
const response = await dynamicFetch('list-form-select/select', 'GET', parameters)
|
||||
return response.data.data[0]
|
||||
} catch (error: any) {
|
||||
// toast.push(
|
||||
// <Notification type="danger" duration={2000}>
|
||||
// ByKey error
|
||||
// {error.toString()}
|
||||
// </Notification>,
|
||||
// {
|
||||
// placement: 'top-end',
|
||||
// },
|
||||
// )
|
||||
return null
|
||||
}
|
||||
},
|
||||
// byKey: async (key) => {
|
||||
// const parameters = getLoadOptions(
|
||||
// { key },
|
||||
// { listFormCode, filter: '', createDeleteQuery: '' },
|
||||
// )
|
||||
|
||||
// parameters.filter = JSON.stringify(parameters.filter)
|
||||
// try {
|
||||
// const response = await dynamicFetch('list-form-select/select', 'GET', parameters)
|
||||
// return response.data.data[0]
|
||||
// } catch (error: any) {
|
||||
// // toast.push(
|
||||
// // <Notification type="danger" duration={2000}>
|
||||
// // ByKey error
|
||||
// // {error.toString()}
|
||||
// // </Notification>,
|
||||
// // {
|
||||
// // placement: 'top-end',
|
||||
// // },
|
||||
// // )
|
||||
// return null
|
||||
// }
|
||||
// },
|
||||
remove: function (key) {
|
||||
if (!gridOptions.deleteServiceAddress) {
|
||||
return
|
||||
|
|
|
|||
|
|
@ -51,12 +51,13 @@ import { useCallback, useEffect, useRef, useState } from 'react'
|
|||
import { Helmet } from 'react-helmet'
|
||||
import SubForms from '../form/SubForms'
|
||||
import { RowMode, SimpleItemWithColData } from '../form/types'
|
||||
import { GridColumnData, GridExtraFilterState } from './GridColumnData'
|
||||
import { GridColumnData } from './GridColumnData'
|
||||
import GridFilterDialogs from './GridFilterDialogs'
|
||||
import {
|
||||
addCss,
|
||||
addJs,
|
||||
controlStyleCondition,
|
||||
GridExtraFilterState,
|
||||
setFormEditingExtraItemValues,
|
||||
setGridPanelColor,
|
||||
} from './Utils'
|
||||
|
|
@ -540,6 +541,8 @@ const Grid = (props: GridProps) => {
|
|||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (gridDto?.gridOptions.extraFilterDto.length === 0) return
|
||||
|
||||
if (gridDto?.gridOptions.extraFilterDto) {
|
||||
setExtraFilters(
|
||||
gridDto.gridOptions.extraFilterDto.map((f) => ({
|
||||
|
|
@ -554,6 +557,7 @@ const Grid = (props: GridProps) => {
|
|||
|
||||
useEffect(() => {
|
||||
if (!searchParams) return
|
||||
if (extraFilters.length === 0) return
|
||||
|
||||
// aktif filtreleri al
|
||||
const activeFilters = extraFilters.filter((f) => f.value)
|
||||
|
|
|
|||
|
|
@ -1,13 +1,6 @@
|
|||
import { DataGridTypes } from 'devextreme-react/data-grid'
|
||||
import { ColumnFormatDto, GridBoxOptionsDto, TagBoxOptionsDto } from '../../proxy/form/models'
|
||||
|
||||
export interface GridExtraFilterState {
|
||||
fieldName: string
|
||||
operator: string
|
||||
controlType: string
|
||||
value: string
|
||||
}
|
||||
|
||||
interface IGridColumnData extends DataGridTypes.Column {
|
||||
colData?: ColumnFormatDto
|
||||
extras?: {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { GridExtraFilterState } from './GridColumnData'
|
||||
import { useState } from 'react'
|
||||
import { GridExtraFilterState } from './Utils'
|
||||
|
||||
export function GridExtraFilterToolbar({
|
||||
filters,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,13 @@ import { DataType } from 'devextreme/common'
|
|||
import { PivotGridDataType } from 'devextreme/ui/pivot_grid/data_source'
|
||||
import { MULTIVALUE_DELIMITER } from '../../constants/app.constant'
|
||||
|
||||
export interface GridExtraFilterState {
|
||||
fieldName: string
|
||||
operator: string
|
||||
controlType: string
|
||||
value: string
|
||||
}
|
||||
|
||||
// sayfaya dinamik olarak css style ekler
|
||||
export function addCss(css: string) {
|
||||
if (css.startsWith('http') || css.startsWith('/')) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue