소스 검색

ahora se puede search en las tablas

table.html ahora tiene la habilidad de buscar/filtrar resultados
부모
커밋
24589968dc
1개의 변경된 파일68개의 추가작업 그리고 23개의 파일을 삭제
  1. 68
    23
      templates/table.html

+ 68
- 23
templates/table.html 파일 보기

@@ -44,39 +44,84 @@
44 44
       {% endraw %}
45 45
     </nav>
46 46
 
47
-    <div class="container-fluid col-12">
48
-      <div class="container-fluid col-12">
49
-        <h1 class="col">
47
+    <div class="container-fluid">
48
+      <div class="row" >
49
+        <h1>
50 50
           {% raw %}
51 51
           {{info.dash_sub_name}}
52 52
           {% endraw %}
53 53
         </h1>
54
-        <div class="col" >
54
+      </div>
55
+      <div class="row" >
56
+        <div class="col-2" >
57
+          <div class="topnav">
58
+            <!-- ################################ con ayuda de w3schools:
59
+                                                How TO - Filter/Search Table-->
60
+            <input type="text" id="myInput" onkeyup="myFunction()" placeholder="Search..">
61
+            <script>
62
+              function myFunction() {
63
+                // Declare variables
64
+                var input, filter, table, tr, td1, td2, td3, i, txtValue1, txtValue2, txtValue3;
65
+                input = document.getElementById("myInput");
66
+                filter = input.value.toUpperCase();
67
+                table = document.getElementById("tabla");
68
+                tr = table.getElementsByTagName("tr");
69
+
70
+                // Loop through all table rows, and hide those who don't match the search query
71
+                for (i = 0; i < tr.length; i++) {
72
+                  td1 = tr[i].getElementsByTagName("td")[0];
73
+                  td2 = tr[i].getElementsByTagName("td")[1];
74
+                  td3 = tr[i].getElementsByTagName("td")[2];
75
+                  if (td1 || td2 || td3) {
76
+                    txtValue1 = td1.textContent || td1.innerText;
77
+                    txtValue2 = td2.textContent || td2.innerText;
78
+                    txtValue3 = td3.textContent || td3.innerText;
79
+                    if ((txtValue1.toUpperCase().indexOf(filter) > -1) ||
80
+                        (txtValue2.toUpperCase().indexOf(filter) > -1) ||
81
+                        (txtValue3.toUpperCase().indexOf(filter) > -1)) {
82
+                      tr[i].style.display = "";
83
+                    } else {
84
+                      tr[i].style.display = "none";
85
+                    }
86
+                  }
87
+                }
88
+              }
89
+              </script>
90
+              <!-- ################################ -->
91
+          </div>
92
+        </div>
93
+        <div class="col-2" >
94
+          <!-- <button href='./' type="submit">Submit</button> -->
95
+        </div>
96
+        <div class="col-4" >
55 97
           {% raw %}
56 98
           <a class="btn button boton mr-4" href="{{info.add_link}}">{{info.add}}</a>
57 99
           {% endraw %}
58 100
         </div>
59 101
       </div>
102
+      <div class="row" >
103
+        <div class="col" >
104
+          <table id='tabla'>
105
+            <tr>
106
+              {% raw %}
107
+              <th ng-repeat="header in headers" class="header2">{{header.nombre}}</th>
108
+              {% endraw %}
109
+            </tr>
110
+            <tr ng-repeat="row in tabla">
111
+              {% raw %}
112
+              <!-- la proxima linea asume que las entradas en la tabla tienen un id unico con -->
113
+              <!-- el mismo nombre de identificador a traves de los javascript, json, etc. -->
114
+              <td ng-repeat="stat in row" ng-if="stat != row.user_id">
115
+                <div ng-bind-html="stat"></div>
116
+              </td>
117
+              <td><button type="button" class="btn2 boton mr-4" name="button" data-toggle="modal" data-target="#myModalv{{row.user_id}}">Ver mas</button></td>
118
+              <td><a type="button" class="btn2 boton mr-4" href="{{info.dir2}}{{row.user_id}}">Editar</a></td>
60 119
 
61
-      <table>
62
-        <tr>
63
-          {% raw %}
64
-          <th ng-repeat="header in headers" class="header2">{{header.nombre}}</th>
65
-          {% endraw %}
66
-        </tr>
67
-        <tr ng-repeat="row in tabla">
68
-          {% raw %}
69
-          <!-- la proxima linea asume que las entradas en la tabla tienen un id unico con -->
70
-          <!-- el mismo nombre de identificador a traves de los javascript, json, etc. -->
71
-          <td ng-repeat="stat in row" ng-if="stat != row.user_id">
72
-            <div ng-bind-html="stat"></div>
73
-          </td>
74
-          <td><button type="button" class="btn2 boton mr-4" name="button" data-toggle="modal" data-target="#myModalv{{row.user_id}}">Ver mas</button></td>
75
-          <td><a type="button" class="btn2 boton mr-4" href="{{info.dir2}}{{row.user_id}}">Editar</a></td>
76
-
77
-          {% endraw %}
78
-        </tr>
79
-      </table>
120
+              {% endraw %}
121
+            </tr>
122
+          </table>
123
+        </div>
124
+      </div>
80 125
     </div>
81 126
   </body>
82 127