Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mySkill-x
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
angular
mySkill-x
Commits
46de48d7
Commit
46de48d7
authored
Apr 02, 2025
by
Nattana Chaiyamat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
syncfution
การจัดการข้อมูลองค์กร ทะเบียนบริษัท หน่วยธุรกิจ ทะเบียนฝ่าย
parent
4ce9024f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
111 additions
and
76 deletions
+111
-76
department-register.component.html
...it/department-register/department-register.component.html
+5
-2
department-register.component.ts
...unit/department-register/department-register.component.ts
+34
-48
datagrid-syncfution.component.html
...ts/datagrid-syncfution/datagrid-syncfution.component.html
+10
-10
datagrid-syncfution.component.ts
...ents/datagrid-syncfution/datagrid-syncfution.component.ts
+62
-16
No files found.
src/app/components/company-components/company-registration/branch-business-unit/department-register/department-register.component.html
View file @
46de48d7
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
<div
class=
"px-1"
>
<div
class=
"px-1"
>
<div
class=
"relative shadow-md"
>
<div
class=
"relative shadow-md"
>
<input
type=
"text"
class=
"ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 "
<input
type=
"text"
class=
"ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 "
placeholder=
"Search by No. or Name"
[(
ngModel
)]="
search
"
(
ngModelChange
)="
searchChange
()"
>
placeholder=
"Search by No. or Name"
[(
ngModel
)]="
search
"
>
<div
<div
class=
"absolute inset-y-0 ltr:left-0 rtl:right-0 flex items-center pointer-events-none z-20 ltr:pl-4 rtl:pr-4"
>
class=
"absolute inset-y-0 ltr:left-0 rtl:right-0 flex items-center pointer-events-none z-20 ltr:pl-4 rtl:pr-4"
>
<i
class=
"ri-search-line text-gray"
></i>
<i
class=
"ri-search-line text-gray"
></i>
...
@@ -66,9 +66,12 @@
...
@@ -66,9 +66,12 @@
<div
class=
"hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)]"
>
<div
class=
"hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)]"
>
<div
class=
"max-h-full overflow-hidden ti-modal-content"
>
<div
class=
"max-h-full overflow-hidden ti-modal-content"
>
<div
class=
"ti-modal-header"
>
<div
class=
"ti-modal-header"
>
<h3
class=
"text-xxl font-bold text-primary"
>
<h3
class=
"text-xxl font-bold text-primary"
*
ngIf=
"currentModel=='add'"
>
เพิ่มข้อมูลทะเบียนฝ่าย
เพิ่มข้อมูลทะเบียนฝ่าย
</h3>
</h3>
<h3
class=
"text-xxl font-bold text-primary"
*
ngIf=
"currentModel=='edit'"
>
แก้ไขข้อมูลทะเบียนฝ่าย
</h3>
<div
class=
"flex justify-end"
>
<div
class=
"flex justify-end"
>
<button
type=
"button"
class=
"hs-dropdown-toggle ti-modal-clode-btn text-danger"
<button
type=
"button"
class=
"hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay=
"#department-register-modal"
>
data-hs-overlay=
"#department-register-modal"
>
...
...
src/app/components/company-components/company-registration/branch-business-unit/department-register/department-register.component.ts
View file @
46de48d7
...
@@ -22,26 +22,25 @@ export class DepartmentRegisterComponent implements OnInit {
...
@@ -22,26 +22,25 @@ export class DepartmentRegisterComponent implements OnInit {
currentModel
:
'add'
|
'edit'
|
'delete'
=
"add"
currentModel
:
'add'
|
'edit'
|
'delete'
=
"add"
bu1
:
{
loading
:
boolean
,
select
:
Bu1Model
,
dataList
:
Bu1Model
[]
}
=
{
loading
:
false
,
select
:
new
MyBu1Model
(),
dataList
:
[]
}
bu1
:
{
loading
:
boolean
,
select
:
Bu1Model
,
dataList
:
Bu1Model
[]
}
=
{
loading
:
false
,
select
:
new
MyBu1Model
(),
dataList
:
[]
}
columns
:
ColumnModel
[]
=
[{
columns
:
ColumnModel
[]
=
[{
"field"
:
"bu1id"
,
field
:
"bu1id"
,
"headerText"
:
"รหัสกลุ่มการอนุมัติ"
,
headerText
:
"รหัสกลุ่มการอนุมัติ"
,
type
:
"string"
,
isPrimaryKey
:
true
,
isPrimaryKey
:
true
,
},
},
{
{
"field"
:
"tdesc"
,
field
:
"tdesc"
,
"headerText"
:
"รายละเอียดฝ่าย(ไทย)"
headerText
:
"รายละเอียดฝ่าย(ไทย)"
,
type
:
"string"
},
},
{
{
"field"
:
"edesc"
,
field
:
"edesc"
,
"headerText"
:
"รายละเอียดฝ่าย(อังกฤษ)"
headerText
:
"รายละเอียดฝ่าย(อังกฤษ)"
,
type
:
"string"
}]
}]
searchSettings
=
{
searchSettings
=
{
fields
:
[
'bu1id'
,
'tdesc'
,
'edesc'
],
fields
:
[
'bu1id'
,
'tdesc'
,
'edesc'
],
operator
:
'contains'
,
operator
:
'contains'
,
ignoreCase
:
true
,
ignoreCase
:
false
// customMatchCase: (cellValue: string, searchValue: string) => {
// return cellValue.toString().toLowerCase() === '00';
// }
};
};
constructor
(
private
bu1Service
:
Bu1Service
,
constructor
(
private
bu1Service
:
Bu1Service
,
private
toastr
:
ToastrService
,
private
toastr
:
ToastrService
,
...
@@ -96,10 +95,8 @@ export class DepartmentRegisterComponent implements OnInit {
...
@@ -96,10 +95,8 @@ export class DepartmentRegisterComponent implements OnInit {
this
.
showAlert
(
error
.
message
,
'error'
)
this
.
showAlert
(
error
.
message
,
'error'
)
}
}
})
})
}
}
getBu1List
()
{
getBu1List
()
{
this
.
bu1
.
loading
=
true
this
.
bu1
.
loading
=
true
this
.
bu1Service
.
getList
().
subscribe
({
this
.
bu1Service
.
getList
().
subscribe
({
...
@@ -109,9 +106,8 @@ export class DepartmentRegisterComponent implements OnInit {
...
@@ -109,9 +106,8 @@ export class DepartmentRegisterComponent implements OnInit {
return
new
MyBu1Model
(
x
)
return
new
MyBu1Model
(
x
)
})
})
this
.
selectedItems
.
key
=
'bu1id'
this
.
selectedItems
.
key
=
'bu1id'
console
.
log
(
" 🐒 this.selectedItems:"
,
this
.
selectedItems
)
this
.
selectedItems
.
count
=
0
this
.
bu1
.
loading
=
false
this
.
bu1
.
loading
=
false
this
.
searchChange
()
this
.
cdr
.
detectChanges
()
this
.
cdr
.
detectChanges
()
},
error
:
error
=>
{
},
error
:
error
=>
{
this
.
bu1
.
loading
=
false
this
.
bu1
.
loading
=
false
...
@@ -119,19 +115,15 @@ export class DepartmentRegisterComponent implements OnInit {
...
@@ -119,19 +115,15 @@ export class DepartmentRegisterComponent implements OnInit {
}
}
})
})
}
}
searchChange
()
{
this
.
currentPage
=
1
this
.
page
=
Array
.
from
({
length
:
Math
.
ceil
(
this
.
bu1ListFilter
().
length
/
10
)
},
(
_
,
i
)
=>
i
+
1
)
}
bu1ListFilter
()
{
return
this
.
bu1
.
dataList
.
filter
(
x
=>
{
return
x
.
bu1id
.
toLowerCase
().
includes
(
this
.
search
.
toLowerCase
())
||
x
.
tdesc
.
toLowerCase
().
includes
(
this
.
search
.
toLowerCase
())
||
x
.
edesc
.
toLowerCase
().
includes
(
this
.
search
.
toLowerCase
())
})
}
selectBu1
(
bu1
?:
Bu1Model
)
{
selectBu1
(
bu1
?:
Bu1Model
)
{
this
.
bu1
.
select
=
new
MyBu1Model
(
bu1
)
if
(
bu1
)
{
this
.
bu1
.
select
=
new
MyBu1Model
(
bu1
)
}
else
if
(
this
.
currentModel
==
'add'
)
{
this
.
bu1
.
select
=
new
MyBu1Model
()
}
else
if
(
this
.
currentModel
==
'edit'
)
{
this
.
bu1
.
select
=
new
MyBu1Model
({
bu1id
:
this
.
bu1
.
select
.
bu1id
})
}
}
}
showAlert
(
text
:
string
,
type
:
'success'
|
'error'
)
{
showAlert
(
text
:
string
,
type
:
'success'
|
'error'
)
{
...
@@ -159,28 +151,22 @@ export class DepartmentRegisterComponent implements OnInit {
...
@@ -159,28 +151,22 @@ export class DepartmentRegisterComponent implements OnInit {
}
}
deleteBu1
()
{
deleteBu1
()
{
this
.
bu1
.
loading
=
true
this
.
bu1
.
loading
=
true
const
body
=
this
.
bu1
.
dataList
.
filter
(
x
=>
{
const
selectedKeys
=
Array
.
from
(
this
.
selectedItems
.
data
.
keys
());
if
(
Array
.
from
(
this
.
selectedItems
.
data
.
keys
()).
find
((
y
:
any
)
=>
y
==
x
.
bu1id
)
&&
Array
.
from
(
this
.
selectedItems
.
data
.
values
()).
find
((
y
:
any
)
=>
y
))
{
const
body
=
this
.
bu1
.
dataList
.
filter
(
x
=>
selectedKeys
.
includes
(
x
.
bu1id
)
&&
this
.
selectedItems
.
data
.
get
(
x
.
bu1id
)).
map
(
x
=>
new
MyBu1Model
(
x
))
return
true
this
.
bu1Service
.
delete
(
body
).
subscribe
({
next
:
response
=>
{
if
(
response
.
success
)
{
this
.
showAlert
(
response
.
message
,
'success'
)
this
.
getBu1List
()
}
else
{
this
.
showAlert
(
response
.
message
,
'error'
)
this
.
bu1
.
loading
=
false
}
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
this
.
bu1
.
loading
=
false
}
}
return
false
})
}
).
map
(
x
=>
new
MyBu1Model
(
x
))
console
.
log
(
" 🐒 body:"
,
body
)
// this.bu1Service.delete(body).subscribe({
// next: response => {
// if (response.success) {
// this.showAlert(response.message, 'success')
// this.getBu1List()
// } else {
// this.showAlert(response.message, 'error')
// this.bu1.loading = false
// }
// }, error: error => {
// this.showAlert(error.message, 'error')
// this.bu1.loading = false
// }
// })
}
}
checkPrimary
()
{
checkPrimary
()
{
...
...
src/app/components/datagrid-syncfution/datagrid-syncfution.component.html
View file @
46de48d7
<ejs-grid
#
grid
id=
'Grid'
[
dataSource
]="
dataSource
"
[
allowFiltering
]="
allowFiltering
"
[
filterSettings
]="
filterSettings
"
<ejs-grid
#
grid
id=
'Grid'
[
dataSource
]="
dataSourceSearch
"
[
allowFiltering
]="
allowFiltering
"
[
searchSettings
]="
searchSettings
"
[
groupSettings
]="
groupSettings
"
[
toolbar
]='
toolbarOptions
'
[
filterSettings
]="
filterSettings
"
(
actionComplete
)="
actionComplete
($
event
)"
[
searchSettings
]="
searchSettings
"
[
editSettings
]="
editSettings
"
showColumnMenu=
'true'
allowPaging=
'true'
allowGrouping=
'true'
allowSorting=
'true'
[
groupSettings
]="
groupSettings
"
[
toolbar
]='
toolbarOptions
'
[
editSettings
]="
editSettings
"
showColumnMenu=
'true'
showColumnMenu=
'true'
allowFiltering=
'true'
[
allowPdfExport
]='
true
'
(
toolbarClick
)='
toolbarClick
($
event
)'
allowPaging=
'true'
allowGrouping=
'true'
allowSorting=
'true'
showColumnMenu=
'true'
allowFiltering=
'true'
[
allowExcelExport
]='
true
'
[
selectionSettings
]="
selectionOptions
"
(
detailDataBound
)='
detailDataBound
($
event
)'
[
allowPdfExport
]='
true
'
(
toolbarClick
)='
toolbarClick
($
event
)'
[
allowExcelExport
]='
true
'
width=
"auto"
allowReordering=
'true'
[
loadingIndicator
]='
loadingIndicator
'
[
query
]="
query
"
rowHeight=
'60'
[
selectionSettings
]="
selectionOptions
"
(
detailDataBound
)='
detailDataBound
($
event
)'
width=
"auto"
allowReordering=
'true'
allowEditing=
'false'
[
pageSettings
]='
initialPage
'
[
allowMultiSorting
]='
true
'
>
[
loadingIndicator
]='
loadingIndicator
'
[
query
]="
query
"
rowHeight=
'60'
allowEditing=
'false'
[
pageSettings
]='
initialPage
'
[
allowMultiSorting
]='
true
'
>
<e-columns>
<e-columns>
<!-- <e-column type='checkbox' width='50' *ngIf="checkBoxSetting"></e-column> -->
<e-column
[
textAlign
]="'
center
'"
*
ngIf=
"checkBoxSetting"
[
allowEditing
]="
false
"
>
<e-column
[
textAlign
]="'
center
'"
*
ngIf=
"checkBoxSetting"
[
allowEditing
]="
false
"
>
<ng-template
#
headerTemplate
let-data
>
<ng-template
#
headerTemplate
let-data
>
<input
type=
"checkbox"
[
id
]="'
checkbox-all
'"
class=
"ti-form-checkbox cursor-pointer"
<input
type=
"checkbox"
[
id
]="'
checkbox-all
'"
class=
"ti-form-checkbox cursor-pointer"
[
checked
]="
selectedItemsAll
"
(
click
)="
toggleSelectionAll
()"
>
[
checked
]="
selectedItemsAll
"
(
click
)="
toggleSelectionAll
()"
>
<label
[
for
]="'
checkbox-all
'"
class=
"
text-sm text-gray-500 mx-2
"
>
<label
[
for
]="'
checkbox-all
'"
class=
"
font-size-12px font-weight-700 text-primary
"
>
{{selectedItems.count}} Selected
</label>
{{selectedItems.count}} Selected
</label>
</ng-template>
</ng-template>
<ng-template
#
template
let-data
>
<ng-template
#
template
let-data
>
<input
type=
"checkbox"
class=
"ti-form-checkbox cursor-pointer"
<input
type=
"checkbox"
class=
"ti-form-checkbox cursor-pointer"
...
...
src/app/components/datagrid-syncfution/datagrid-syncfution.component.ts
View file @
46de48d7
...
@@ -8,11 +8,31 @@ import {
...
@@ -8,11 +8,31 @@ import {
ViewChild
,
ViewChild
,
SimpleChanges
SimpleChanges
}
from
'@angular/core'
;
}
from
'@angular/core'
;
import
{
EditService
,
ReorderService
,
SortService
,
GroupService
,
ColumnMenuService
,
PageService
,
FilterService
,
SelectionSettingsModel
,
ToolbarItems
,
ToolbarService
,
GridComponent
,
PdfExportService
,
ExcelExportService
,
DetailRowService
,
DetailDataBoundEventArgs
,
Grid
,
AggregateService
,
PdfExportProperties
,
LoadingIndicatorModel
}
from
'@syncfusion/ej2-angular-grids'
;
import
{
EditService
,
SearchService
,
ReorderService
,
SortService
,
GroupService
,
ColumnMenuService
,
PageService
,
FilterService
,
SelectionSettingsModel
,
ToolbarItems
,
ToolbarService
,
GridComponent
,
PdfExportService
,
ExcelExportService
,
DetailRowService
,
DetailDataBoundEventArgs
,
Grid
,
AggregateService
,
PdfExportProperties
,
LoadingIndicatorModel
}
from
'@syncfusion/ej2-angular-grids'
;
import
{
GroupSettingsModel
,
FilterSettingsModel
,
ColumnModel
}
from
'@syncfusion/ej2-angular-grids'
;
import
{
GroupSettingsModel
,
FilterSettingsModel
,
ColumnModel
}
from
'@syncfusion/ej2-angular-grids'
;
import
{
DataManager
,
Query
}
from
'@syncfusion/ej2-data'
;
import
{
DataManager
,
Query
}
from
'@syncfusion/ej2-data'
;
import
{
L10n
,
setCulture
}
from
'@syncfusion/ej2-base'
;
import
{
L10n
,
setCulture
}
from
'@syncfusion/ej2-base'
;
setCulture
(
'th-TH'
);
setCulture
(
'th-TH'
);
L10n
.
load
({
L10n
.
load
({
...
@@ -48,17 +68,23 @@ L10n.load({
...
@@ -48,17 +68,23 @@ L10n.load({
selector
:
'app-datagrid-syncfution'
,
selector
:
'app-datagrid-syncfution'
,
templateUrl
:
'./datagrid-syncfution.component.html'
,
templateUrl
:
'./datagrid-syncfution.component.html'
,
styleUrls
:
[
'./datagrid-syncfution.component.scss'
],
styleUrls
:
[
'./datagrid-syncfution.component.scss'
],
providers
:
[
AggregateService
,
SortService
,
GroupService
,
ColumnMenuService
,
PageService
,
FilterService
,
ToolbarService
,
PdfExportService
,
ExcelExportService
,
DetailRowService
,
ReorderService
,
EditService
],
providers
:
[
AggregateService
,
SortService
,
GroupService
,
ColumnMenuService
,
PageService
,
FilterService
,
ToolbarService
,
PdfExportService
,
ExcelExportService
,
DetailRowService
,
ReorderService
,
EditService
,
SearchService
],
encapsulation
:
ViewEncapsulation
.
None
encapsulation
:
ViewEncapsulation
.
None
})
})
export
class
DatagridSyncfutionComponent
implements
OnInit
{
export
class
DatagridSyncfutionComponent
implements
OnInit
{
@
ViewChild
(
'grid'
)
public
grid
?:
GridComponent
;
@
ViewChild
(
'grid'
)
public
grid
?:
GridComponent
;
@
Input
()
dataSource
:
any
[]
=
[];
@
Input
()
dataSource
:
any
[]
=
[];
dataSourceSearch
:
any
[]
=
[];
dataSourceFilter
:
any
[]
=
[];
@
Output
()
sendSelectData
=
new
EventEmitter
<
any
>
();
@
Output
()
sendSelectData
=
new
EventEmitter
<
any
>
();
@
Input
()
columns
:
ColumnModel
[]
=
[];
@
Input
()
columns
:
ColumnModel
[]
=
[];
// @Input() toolbarOptions?: ToolbarItems[]
// @Input() toolbarOptions?: ToolbarItems[]
@
Input
()
toolbarOptions
?:
ToolbarItems
[]
=
[
'Print'
,
'ExcelExport'
,
'CsvExport'
];
@
Input
()
toolbarOptions
?:
ToolbarItems
[]
=
[
'Print'
,
'ExcelExport'
,
'CsvExport'
];
@
Input
()
searchSettings
=
{}
@
Input
()
searchSettings
:
any
=
{
fields
:
[],
operator
:
'contains'
,
ignoreCase
:
true
,
};
@
Input
()
selectedItems
:
{
key
:
string
,
count
:
number
,
data
:
Map
<
string
,
boolean
>
}
=
{
key
:
''
,
count
:
0
,
data
:
new
Map
<
string
,
boolean
>
()
};
@
Input
()
selectedItems
:
{
key
:
string
,
count
:
number
,
data
:
Map
<
string
,
boolean
>
}
=
{
key
:
''
,
count
:
0
,
data
:
new
Map
<
string
,
boolean
>
()
};
selectedItemsAll
=
false
selectedItemsAll
=
false
@
Output
()
sendSelectedItems
=
new
EventEmitter
<
any
>
();
@
Output
()
sendSelectedItems
=
new
EventEmitter
<
any
>
();
...
@@ -90,7 +116,6 @@ export class DatagridSyncfutionComponent implements OnInit {
...
@@ -90,7 +116,6 @@ export class DatagridSyncfutionComponent implements OnInit {
// ตัวอย่าง event เมื่อมีการลบ / แก้ไข
// ตัวอย่าง event เมื่อมีการลบ / แก้ไข
@
Output
()
actionBegin
=
new
EventEmitter
<
any
>
();
@
Output
()
actionBegin
=
new
EventEmitter
<
any
>
();
@
Output
()
actionComplete
=
new
EventEmitter
<
any
>
();
// อาจมี event อื่น ๆ เช่น pageChange, filterChange, ฯลฯ
// อาจมี event อื่น ๆ เช่น pageChange, filterChange, ฯลฯ
// แล้วแต่ logic ที่ต้องการให้ parent รู้
// แล้วแต่ logic ที่ต้องการให้ parent รู้
// @Output() pageChanged = new EventEmitter<number>();
// @Output() pageChanged = new EventEmitter<number>();
...
@@ -108,17 +133,20 @@ export class DatagridSyncfutionComponent implements OnInit {
...
@@ -108,17 +133,20 @@ export class DatagridSyncfutionComponent implements OnInit {
this
.
query
=
new
Query
().
addParams
(
'dataCount'
,
'1000'
);
this
.
query
=
new
Query
().
addParams
(
'dataCount'
,
'1000'
);
this
.
loadingIndicator
=
{
indicatorType
:
'Shimmer'
};
this
.
loadingIndicator
=
{
indicatorType
:
'Shimmer'
};
if
(
changes
)
{
if
(
changes
)
{
console
.
log
(
'this.dataSource'
,
this
.
dataSource
)
if
(
changes
[
'searchText'
])
{
if
(
changes
[
'searchText'
])
{
this
.
search
(
changes
[
'searchText'
].
currentValue
)
this
.
search
(
changes
[
'searchText'
].
currentValue
)
}
}
if
(
changes
[
'dataSource'
])
{
this
.
dataSourceSearch
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
dataSource
||
[]))
this
.
dataSourceFilter
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
dataSource
||
[]))
}
}
}
}
}
onSelectData
(
args
:
any
)
{
onSelectData
(
args
:
any
)
{
this
.
sendSelectData
.
emit
(
args
);
this
.
sendSelectData
.
emit
(
args
);
}
}
onNextPage
(
args
:
any
)
{
onNextPage
(
args
:
any
)
{
console
.
log
(
args
)
//
console.log(args)
}
}
toolbarClick
(
args
:
any
):
void
{
toolbarClick
(
args
:
any
):
void
{
...
@@ -133,15 +161,23 @@ export class DatagridSyncfutionComponent implements OnInit {
...
@@ -133,15 +161,23 @@ export class DatagridSyncfutionComponent implements OnInit {
search
(
text
:
string
)
{
search
(
text
:
string
)
{
if
(
this
.
grid
)
{
if
(
this
.
grid
)
{
(
this
.
grid
as
GridComponent
).
search
(
this
.
searchText
);
if
(
this
.
searchSettings
.
fields
.
length
)
{
// let filteredData = (this.grid as GridComponent).getCurrentViewRecords();
this
.
dataSourceSearch
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
filterData
(
text
,
this
.
searchSettings
.
fields
)));
// console.log(filteredData);
this
.
dataSourceFilter
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
filterData
(
text
,
this
.
searchSettings
.
fields
)));
// const clonedData = JSON.parse(JSON.stringify(this.dataSource));
}
else
{
// new DataManager(clonedData).executeQuery(new Query().search(this.searchText, [], undefined, true)).then((e: any) => {
(
this
.
grid
as
GridComponent
).
search
(
text
);
// console.log('Searched Records:', e.result)
}
// });
}
}
}
}
filterData
(
text
:
string
,
fields
:
string
[]):
any
[]
{
return
this
.
dataSource
.
filter
(
item
=>
{
return
fields
.
some
(
field
=>
item
[
field
]?.
toString
().
toLowerCase
().
includes
(
text
.
toLowerCase
())
);
});
}
detailDataBound
(
e
:
DetailDataBoundEventArgs
)
{
detailDataBound
(
e
:
DetailDataBoundEventArgs
)
{
let
detail
=
new
Grid
({
let
detail
=
new
Grid
({
...
@@ -174,9 +210,19 @@ export class DatagridSyncfutionComponent implements OnInit {
...
@@ -174,9 +210,19 @@ export class DatagridSyncfutionComponent implements OnInit {
toggleSelectionAll
()
{
toggleSelectionAll
()
{
this
.
selectedItemsAll
=
!
this
.
selectedItemsAll
;
this
.
selectedItemsAll
=
!
this
.
selectedItemsAll
;
this
.
selectedItems
.
data
.
forEach
((
_
,
key
)
=>
{
this
.
selectedItems
.
data
.
forEach
((
_
,
key
)
=>
{
this
.
selectedItems
.
data
.
set
(
key
,
this
.
selectedItemsAll
);
if
(
this
.
dataSourceFilter
.
find
((
x
:
any
)
=>
x
[
this
.
selectedItems
.
key
]
==
key
))
{
this
.
selectedItems
.
data
.
set
(
key
,
this
.
selectedItemsAll
);
}
});
});
this
.
selectedItems
.
count
=
this
.
selectedItemsAll
?
this
.
selectedItems
.
data
.
size
:
0
;
this
.
selectedItems
.
count
=
Array
.
from
(
this
.
selectedItems
.
data
.
values
()).
filter
(
v
=>
v
).
length
;
this
.
sendSelectedItems
.
emit
(
this
.
selectedItems
);
this
.
sendSelectedItems
.
emit
(
this
.
selectedItems
);
}
}
actionComplete
(
args
:
any
)
{
if
(
args
.
requestType
===
'filtering'
)
{
if
(
this
.
grid
)
{
this
.
dataSourceFilter
=
((
this
.
grid
as
GridComponent
).
getFilteredRecords
()
as
any
).
length
?
((
this
.
grid
as
GridComponent
).
getFilteredRecords
()
as
any
)
:
JSON
.
parse
(
JSON
.
stringify
(
this
.
dataSourceSearch
||
[]));
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment