File tree Expand file tree Collapse file tree 3 files changed +20
-20
lines changed
2-ui/2-events/03-event-delegation/3-sortable-table Expand file tree Collapse file tree 3 files changed +20
-20
lines changed Original file line number Diff line number Diff line change 2525 < table id ="grid ">
2626 < thead >
2727 < tr >
28- < th data-type ="number "> Age </ th >
29- < th data-type ="string "> Name </ th >
28+ < th data-type ="number "> Umur </ th >
29+ < th data-type ="string "> Nama </ th >
3030 </ tr >
3131 </ thead >
3232 < tbody >
5959 if ( e . target . tagName != 'TH' ) return ;
6060
6161 let th = e . target ;
62- // if TH, then sort
63- // cellIndex is the number of th:
64- // 0 for the first column
65- // 1 for the second column, etc
62+ // Jika TH, maka urutkan
63+ // cellIndex adalah nomor dari th:
64+ // 0 untuk kolom pertama
65+ // 1 untuk kolom kedua, dan seterusnya
6666 sortGrid ( th . cellIndex , th . dataset . type ) ;
6767 } ;
6868
7171
7272 let rowsArray = Array . from ( tbody . rows ) ;
7373
74- // compare (a, b) compares two rows, need for sorting
74+ // bandingkan (a, b) bandikna kedua baris, untuk di urutkan
7575 let compare ;
7676
7777 switch ( type ) {
8787 break ;
8888 }
8989
90- // sort
90+ // urutkan
9191 rowsArray . sort ( compare ) ;
9292
9393 tbody . append ( ...rowsArray ) ;
Original file line number Diff line number Diff line change 2525 < table id ="grid ">
2626 < thead >
2727 < tr >
28- < th data-type ="number "> Age </ th >
29- < th data-type ="string "> Name </ th >
28+ < th data-type ="number "> Umur </ th >
29+ < th data-type ="string "> Nama </ th >
3030 </ tr >
3131 </ thead >
3232 < tbody >
5454 </ table >
5555
5656 < script >
57- // ...your code ...
57+ // ...Kode kamu ...
5858 </ script >
5959
6060</ body >
Original file line number Diff line number Diff line change @@ -2,19 +2,19 @@ importance: 4
22
33---
44
5- # Sortable table
5+ # Tabel yang bisa diurutkan
66
7- Make the table sortable: clicks on ` <th> ` elements should sort it by corresponding column .
7+ Buat sebuah table yang dapat diurutkan: klik pada elemen ` <th> ` harus mengurutkan kolom dibawahnya .
88
9- Each ` <th> ` has the type in the attribute, like this :
9+ Setiap ` <th> ` memiliki tipe pada atribut, seperti ini :
1010
1111``` html
1212<table id =" grid" >
1313 <thead >
1414 <tr >
1515*!*
16- <th data-type =" number" >Age </th >
17- <th data-type =" string" >Name </th >
16+ <th data-type =" number" >Umur </th >
17+ <th data-type =" string" >Nama </th >
1818*/!*
1919 </tr >
2020 </thead >
@@ -32,12 +32,12 @@ Each `<th>` has the type in the attribute, like this:
3232</table >
3333```
3434
35- In the example above the first column has numbers, and the second one -- strings. The sorting function should handle sort according to the type .
35+ Pada contoh diatas kolom memiliki nomor, dan kolom kedua - string (teks). Fungsi pengurutan harus menanggani pengurutan berdasarkan tipenya .
3636
37- Only ` "string" ` and ` "number" ` types should be supported .
37+ Hanya tipe ` "string" ` dan ` "number" ` yang bisa di urutkan .
3838
39- The working example :
39+ Contoh yang sudah jadi :
4040
4141[ iframe border=1 src="solution" height=190]
4242
43- P.S. The table can be big, with any number of rows and columns .
43+ Tambahan: Tabel bisa besar, dengan banyak baris dan kolom .
You can’t perform that action at this time.
0 commit comments