diff app/query-result-table.component.ts @ 30:193271b6b9d2

configure attributes per result type. select number of items per result page.
author casties
date Mon, 01 Feb 2016 17:29:04 +0100
parents 52af480a843e
children 4926885f8a99
line wrap: on
line diff
--- a/app/query-result-table.component.ts	Wed Jan 27 16:25:00 2016 +0100
+++ b/app/query-result-table.component.ts	Mon Feb 01 17:29:04 2016 +0100
@@ -16,6 +16,14 @@
         <div *ngIf="showTable"><button (click)="showTable=false">hide results</button></div>
         <div *ngIf="!showTable"><button (click)="showTable=true">show results</button></div>
         <div *ngIf="showTable">
+            <div>Show 
+                <select (change)="onSelectNumItems($event)">
+                    <option value="10">10</option>
+                    <option value="100">100</option>
+                    <option value="0">all</option>
+                </select>
+                results per page.
+            </div>
             <div *ngIf="config.paging">Page {{page}} of {{numPages}}</div>
             <pagination *ngIf="config.paging"
                         class="pagination-sm"
@@ -76,6 +84,17 @@
         console.debug("result table init!");
     }
     
+    onSelectNumItems(event: any) {
+        let selected = event.target.value;
+        console.debug("selected number of items:", selected);
+        let num = parseInt(selected);
+        if (num == 0) {
+            this.itemsPerPage = this.length;
+        } else {
+            this.itemsPerPage = num;
+        }
+    }
+    
     changePage(page:any, data:Array<any> = this.data):Array<any> {
         let start = (page.page - 1) * page.itemsPerPage;
         let end = page.itemsPerPage > -1 ? (start + page.itemsPerPage) : data.length;