@@ -9,82 +9,41 @@ import Pagination from "./pagination";
99
1010class RecordTable extends PureComponent {
1111 state = {
12- error : false ,
13- isLoading : false ,
1412 columns : [
1513 {
1614 Header : "" ,
17- commentHeader : "" ,
1815 Value : "" ,
19- commentValue : "" ,
2016 sortOn : "" ,
2117 childItem : null ,
2218 } , {
2319 Header : "Id" ,
24- commentHeader : "Id" ,
2520 Value : "id" ,
26- commentValue : "id" ,
2721 sortOn : "id" ,
2822 childItem : null ,
2923 } , {
3024 Header : "Name" ,
31- commentHeader : "Name" ,
3225 Value : "name" ,
33- commentValue : "name" ,
3426 sortOn : "name" ,
3527 childItem : null ,
36- } , {
37- Header : "username" ,
38- commentHeader : "" ,
39- Value : "username" ,
40- commentValue : "" ,
41- sortOn : "username" ,
42- childItem : null ,
4328 } , {
4429 Header : "Email" ,
45- commentHeader : "Email" ,
4630 Value : "email" ,
47- commentValue : "email" ,
4831 sortOn : "email" ,
4932 childItem : null ,
5033 } , {
51- Header : "Phone" ,
52- commentHeader : "" ,
53- Value : "phone" ,
54- commentValue : "" ,
55- sortOn : "phone" ,
56- childItem : null ,
57- } , {
58- Header : "Website" ,
59- commentHeader : "" ,
60- Value : "website" ,
61- commentValue : "" ,
62- sortOn : "website" ,
63- childItem : null ,
64- } , {
65- Header : "Address" ,
66- commentHeader : "" ,
67- Value : "address.city" ,
68- commentValue : "" ,
69- sortOn : "adress.city" ,
70- childItem : [
71- {
72- Value : "address.zipcode" ,
73- } , {
74- Value : "address.street" ,
75- }
76- ] ,
77- } , {
78- Header : "" ,
79- commentHeader : "Comment" ,
34+ Header : "Comment" ,
8035 Value : "" ,
81- commentValue : "body" ,
8236 sortOn : "body" ,
83- childItem : null ,
84- } ,
37+ childItem :[
38+ {
39+ Value : "body" ,
40+ } ,
41+ ]
42+ } ,
8543 ] ,
44+ error : false ,
45+ isLoading : false ,
8646 data : [ ] ,
87- checked : false ,
8847 currentPage : 1 ,
8948 recordsPerPage : 30 ,
9049
@@ -101,10 +60,8 @@ class RecordTable extends PureComponent {
10160 }
10261 // Initial call to the server for records
10362 loadDataFromServer = ( ) => {
104- const { checked } = this . state ;
105-
10663 const xmlhr = new XMLHttpRequest ( ) ;
107- const url = ! checked ? `https://jsonplaceholder.typicode.com/comments` : `https://jsonplaceholder.typicode.com/users `;
64+ const url = `https://jsonplaceholder.typicode.com/comments` ;
10865 this . setState ( { isLoading : true } ) ;
10966
11067 xmlhr . open ( "GET" , url , true ) ;
@@ -124,7 +81,7 @@ class RecordTable extends PureComponent {
12481 }
12582 }
12683 } ;
127- xmlhr . send ( ) ;
84+ xmlhr . send ( ) ;
12885 }
12986 // Column Sort handler + Logic
13087 columnSort = ( key ) => {
@@ -135,7 +92,6 @@ class RecordTable extends PureComponent {
13592 a [ key ] > b [ key ] :
13693 b [ key ] > a [ key ] )
13794 ) ;
138-
13995 this . setState ( {
14096 data : newData ,
14197 sortOrder : {
@@ -152,20 +108,10 @@ class RecordTable extends PureComponent {
152108 query : query ,
153109 } ) ;
154110 }
155- handleCheckBox = ( ) => {
156- const { checked } = this . state ;
157- this . setState ( {
158- recordsPerPage : 30 ,
159- checked : ! checked ,
160- query : "" ,
161- } ) ;
162- this . loadDataFromServer ( ) ;
163- }
164111 //Pagination
165112 handlePageChange = ( event ) => {
166113 const currentPage = Number ( event . target . id ) ;
167114 const type = event . target . textContent ;
168- console . log ( "TCL: RecordTable -> handlePageChange -> type" , type )
169115
170116 this . setState ( {
171117 currentPage : currentPage ,
@@ -191,7 +137,7 @@ class RecordTable extends PureComponent {
191137 }
192138 render ( ) {
193139 const { error, isLoading, data, columns, query, PlaceHolder,
194- currentPage, recordsPerPage, checked
140+ currentPage, recordsPerPage
195141 } = this . state ;
196142
197143 const indexOfLastRecord = currentPage * recordsPerPage ;
@@ -218,13 +164,6 @@ class RecordTable extends PureComponent {
218164 placeholder = { PlaceHolder }
219165 onChange = { this . tableSearchFilter }
220166 />
221- < div id = "checkbox" >
222- < input
223- type = "checkbox"
224- id = "checkBox"
225- onClick = { this . handleCheckBox }
226- defaultChecked = "true" /> < strong > Change Data</ strong >
227- </ div >
228167 </ form >
229168
230169 if ( error ) {
@@ -236,20 +175,20 @@ class RecordTable extends PureComponent {
236175 </ div >
237176 ) ;
238177 }
239-
178+
240179 return (
241180 < div >
242181 { recordFilter }
243182 < table id = "dataTable" >
244- < TableHeaders columns = { columns } checked = { checked } columnSort = { this . columnSort } />
183+ < TableHeaders columns = { columns } columnSort = { this . columnSort } />
245184 {
246185 tableData . map ( ( record , key ) => {
247186 return (
248187 < TableRows
249188 key = { key }
250189 columns = { columns }
251190 data = { record }
252- checked = { checked }
191+ id = { console . log ( columns ) }
253192 />
254193 ) ;
255194 } )
0 commit comments