From 637bc5807de715eaf40f64f17a245fc2043b9a0a Mon Sep 17 00:00:00 2001 From: Akshay Anand Date: Wed, 12 Jul 2017 21:49:38 -0400 Subject: [PATCH] number sort bug fix, allow hiding column, label position fix --- README.md | 43 ++++++++++++++++++++++------------------ dev/App.vue | 9 +++++---- src/components/Table.vue | 11 +++++----- 3 files changed, 35 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 46bd2803..b2bc7e9a 100644 --- a/README.md +++ b/README.md @@ -77,23 +77,23 @@ export default { }, ], rows: [ - {id:1, name:"John",age:"20",createdAt: '201-10-31:9:35 am',score: 0.03343}, - {id:2, name:"Jane",age:"24",createdAt: '2011-10-31',score: 0.03343}, - {id:3, name:"Susan",age:"16",createdAt: '2011-10-30',score: 0.03343}, - {id:4, name:"Chris",age:"55",createdAt: '2011-10-11',score: 0.03343}, - {id:5, name:"Dan",age:"40",createdAt: '2011-10-21',score: 0.03343}, - {id:6, name:"John",age:"20",createdAt: '2011-10-31',score: 0.03343}, - {id:7, name:"Jane",age:"24",createdAt: '20111031'}, - {id:8, name:"Susan",age:"16",createdAt: '2013-10-31',score: 0.03343}, - {id:9, name:"Chris",age:"55",createdAt: '2012-10-31',score: 0.03343}, - {id:10, name:"Dan",age:"40",createdAt: '2011-10-31',score: 0.03343}, - {id:11, name:"John",age:"20",createdAt: '2011-10-31',score: 0.03343}, - {id:12, name:"Jane",age:"24",createdAt: '2011-07-31',score: 0.03343}, - {id:13, name:"Susan",age:"16",createdAt: '2017-02-28',score: 0.03343}, - {id:14, name:"Chris",age:"55",createdAt: '',score: 0.03343}, - {id:15, name:"Dan",age:"40",createdAt: '2011-10-31',score: 0.03343}, - {id:19, name:"Chris",age:"55",createdAt: '2011-10-31',score: 0.03343}, - {id:20, name:"Dan",age:"40",createdAt: '2011-10-31',score: 0.03343}, + {id:1, name:"John",age:20,createdAt: '201-10-31:9:35 am',score: 0.03343}, + {id:2, name:"Jane",age:24,createdAt: '2011-10-31',score: 0.03343}, + {id:3, name:"Susan",age:16,createdAt: '2011-10-30',score: 0.03343}, + {id:4, name:"Chris",age:55,createdAt: '2011-10-11',score: 0.03343}, + {id:5, name:"Dan",age:40,createdAt: '2011-10-21',score: 0.03343}, + {id:6, name:"John",age:20,createdAt: '2011-10-31',score: 0.03343}, + {id:7, name:"Jane",age:24,createdAt: '20111031'}, + {id:8, name:"Susan",age:16,createdAt: '2013-10-31',score: 0.03343}, + {id:9, name:"Chris",age:55,createdAt: '2012-10-31',score: 0.03343}, + {id:10, name:"Dan",age:40,createdAt: '2011-10-31',score: 0.03343}, + {id:11, name:"John",age:20,createdAt: '2011-10-31',score: 0.03343}, + {id:12, name:"Jane",age:24,createdAt: '2011-07-31',score: 0.03343}, + {id:13, name:"Susan",age:16,createdAt: '2017-02-28',score: 0.03343}, + {id:14, name:"Chris",age:55,createdAt: '',score: 0.03343}, + {id:15, name:"Dan",age:40,createdAt: '2011-10-31',score: 0.03343}, + {id:19, name:"Chris",age:55,createdAt: '2011-10-31',score: 0.03343}, + {id:20, name:"Dan",age:40,createdAt: '2011-10-31',score: 0.03343}, ], }; }, @@ -166,7 +166,7 @@ This should result in the screenshot seen above { id:1, name:"John", - age:"20" + age:20 }, //... ] @@ -249,7 +249,7 @@ data() { externalSearchQuery Allows global search via your own input field - Usage:
+ Usage
     <input type="text" v-model="searchTerm" />
     <vue-good-table
@@ -363,6 +363,11 @@ data() {
       provide a width value for this column
       example: width: '50px'
     
+    
+      hidden (optional)
+      allow hiding a column on table
+      Boolean
+    
     
       tdClass (optional)
       provide custom class(es) to the td
diff --git a/dev/App.vue b/dev/App.vue
index fc448283..82c4b9ea 100644
--- a/dev/App.vue
+++ b/dev/App.vue
@@ -3,6 +3,7 @@
     
   
 
@@ -28,10 +29,10 @@
           },
         ],
         rows: [
-          {name: "John", age: "20"},
-          {name: "Jane", age: "24"},
-          {name: "Susan", age: "16"},
-          {name: "Chris", age: "55"},
+          {name: "John", age: "103"},
+          {name: "Jane", age: "114"},
+          {name: "Susan", age: "12"},
+          {name: "Chris", age: "121"},
           {name: "Dan", age: "40"},
           {name: "Cankut", age: "20"},
           {name: "Aylin", age: "24"},
diff --git a/src/components/Table.vue b/src/components/Table.vue
index 797b4301..2ccaf937 100644
--- a/src/components/Table.vue
+++ b/src/components/Table.vue
@@ -22,7 +22,8 @@
           
+            :style="{width: column.width ? column.width : 'auto'}"
+            v-if="!column.hidden">
             {{column.label}}
           
           
@@ -41,7 +42,7 @@
         
           {{ getCurrentIndex(index) }}
           
-            
+            
               {{ collectFormatted(row, column) }}
               
             
@@ -69,11 +70,11 @@
       
@@ -412,7 +413,7 @@ import format from 'date-fns/format';
               
               if (typeof(x) === 'string') {
                 x = x.toLowerCase();
-                if (this.columns[this.sortColumn].numeric)
+                if (this.columns[this.sortColumn].type == 'number')
                   x = x.indexOf('.') >= 0 ? parseFloat(x) : parseInt(x);
               }