55 Page , Inject , ContextMenu , CommandColumn , Freeze , LazyLoadGroup , RecordClickEventArgs , RowInfo ,
66 ExcelExport , Column , Search // <-- add Search
77} from '@syncfusion/ej2-react-grids' ;
8- import { DataManager , UrlAdaptor , DataUtil } from '@syncfusion/ej2-data' ;
8+ import { DataManager , UrlAdaptor , DataUtil , Query } from '@syncfusion/ej2-data' ;
99import { useNavigate } from 'react-router-dom' ;
1010import { useRef , useEffect } from 'react' ;
1111import { TooltipComponent , TooltipEventArgs } from '@syncfusion/ej2-react-popups' ;
@@ -16,9 +16,24 @@ import './Employees.css';
1616
1717DataUtil . serverTimezoneOffset = 0 ;
1818
19- const data : DataManager = new DataManager ( {
19+
20+ const MAX_COUNT = 3000 ;
21+
22+ class CappedUrlAdaptor extends UrlAdaptor {
23+ public processResponse ( data : any , ds : any , query : Query , xhr : any , request : any , changes ?: any ) {
24+ const res : any = super . processResponse ( data , ds , query , xhr , request , changes ) ;
25+ // res can be array or { result, count } depending on server
26+ if ( res && typeof res === 'object' && 'result' in res && 'count' in res ) {
27+ // Clamp the reported total
28+ res . count = Math . min ( res . count ?? 0 , MAX_COUNT ) ;
29+ }
30+ return res ;
31+ }
32+ }
33+
34+ const data = new DataManager ( {
2035 url : 'https://ej2services.syncfusion.com/aspnet/development/api/EmployeesData' ,
21- adaptor : new UrlAdaptor ( ) ,
36+ adaptor : new CappedUrlAdaptor ( ) ,
2237} ) ;
2338
2439type EmployeesProps = {
@@ -169,7 +184,7 @@ const Employees = (props?: EmployeesProps) => {
169184 } ;
170185
171186 return (
172- < div className = "employees-content" >
187+ < div className = "employees-content" >
173188 < TooltipComponent
174189 id = "content"
175190 cssClass = "e-tooltip-template-css"
@@ -183,10 +198,10 @@ const Employees = (props?: EmployeesProps) => {
183198 ref = { gridRef }
184199 dataSource = { data }
185200 allowPaging = { true }
186- pageSettings = { { pageCount : 4 , pageSize : 15 } }
201+ pageSettings = { { pageCount : 8 , pageSize : 12 } }
187202 allowExcelExport = { true }
188203 //width={'100%'}
189- // height={'100%'}
204+ height = { '100%' }
190205
191206 allowGrouping = { true }
192207 groupSettings = { { enableLazyLoading : true } }
@@ -218,24 +233,23 @@ const Employees = (props?: EmployeesProps) => {
218233 headerText = "Employee ID"
219234 template = { codeTemplate }
220235 customAttributes = { { class : 'infotooltip' } }
221- width = "140 "
236+ width = "120 "
222237 />
223238 < ColumnDirective field = "Name" template = { nameTemplate } customAttributes = { { class : 'infotooltip' } } width = "150" />
224- < ColumnDirective field = "Mail" headerText = "Email ID" clipMode = "EllipsisWithTooltip" width = "260 " />
225- < ColumnDirective field = "Designation" clipMode = "EllipsisWithTooltip" width = "260 " />
239+ < ColumnDirective field = "Mail" headerText = "Email ID" clipMode = "EllipsisWithTooltip" width = "230 " />
240+ < ColumnDirective field = "Designation" clipMode = "EllipsisWithTooltip" width = "220 " />
226241 < ColumnDirective
227242 field = "DateOfJoining"
228243 headerText = "Date Joined"
229- textAlign = "Right"
230244 type = "date"
231245 format = { { type : 'date' , format : "MMM d yyyy" } }
232246 clipMode = "EllipsisWithTooltip"
233- width = "150 "
247+ width = "100 "
234248 />
235- < ColumnDirective field = "Branch" clipMode = "EllipsisWithTooltip" width = "120 " />
236- < ColumnDirective field = "Team" headerText = "Team(s)" clipMode = "EllipsisWithTooltip" width = "220 " />
237- < ColumnDirective field = "TeamLead" headerText = "Reporter" clipMode = "EllipsisWithTooltip" width = "150 " />
238- < ColumnDirective field = "ManagerName" headerText = "Manager" clipMode = "EllipsisWithTooltip" width = "150 " />
249+ < ColumnDirective field = "Branch" clipMode = "EllipsisWithTooltip" width = "100 " />
250+ < ColumnDirective field = "Team" headerText = "Team(s)" clipMode = "EllipsisWithTooltip" width = "170 " />
251+ < ColumnDirective field = "TeamLead" headerText = "Reporter" clipMode = "EllipsisWithTooltip" width = "130 " />
252+ < ColumnDirective field = "ManagerName" headerText = "Manager" clipMode = "EllipsisWithTooltip" width = "140 " />
239253 </ ColumnsDirective >
240254 < Inject
241255 // IMPORTANT: include Search here so the toolbar Search works with remote data
0 commit comments