Skip to content

Commit

Permalink
number sort bug fix, allow hiding column, label position fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xaksis committed Jul 13, 2017
1 parent 8f7a187 commit 637bc58
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 28 deletions.
43 changes: 24 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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},
],
};
},
Expand Down Expand Up @@ -166,7 +166,7 @@ This should result in the screenshot seen above
{
id:1,
name:"John",
age:"20"
age:20
},
//...
]
Expand Down Expand Up @@ -249,7 +249,7 @@ data() {
<tr>
<td>externalSearchQuery</td>
<td>Allows global search via your own input field</td>
<td>Usage: <br>
<td>Usage<br>
<pre lang="html">
&lt;input type=&quot;text&quot; v-model=&quot;searchTerm&quot; /&gt;
&lt;vue-good-table
Expand Down Expand Up @@ -363,6 +363,11 @@ data() {
<td>provide a width value for this column</td>
<td>example: <code>width: '50px'</code></td>
</tr>
<tr>
<td>hidden (optional)</td>
<td>allow hiding a column on table</td>
<td>Boolean</td>
</tr>
<tr>
<td>tdClass (optional)</td>
<td>provide custom class(es) to the td</td>
Expand Down
9 changes: 5 additions & 4 deletions dev/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<vue-good-table
:columns="columns"
:paginate="true"
:lineNumbers="true"
:rows="rows"/>
</div>
</template>
Expand All @@ -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"},
Expand Down
11 changes: 6 additions & 5 deletions src/components/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
<th v-for="(column, index) in columns"
@click="sort(index)"
:class="columnHeaderClass(column, index)"
:style="{width: column.width ? column.width : 'auto'}">
:style="{width: column.width ? column.width : 'auto'}"
v-if="!column.hidden">
<span>{{column.label}}</span>
</th>
<slot name="thead-tr"></slot>
Expand All @@ -41,7 +42,7 @@
<tr v-for="(row, index) in paginated" :class="onClick ? 'clickable' : ''" @click="click(row, index)">
<th v-if="lineNumbers" class="line-numbers">{{ getCurrentIndex(index) }}</th>
<slot name="table-row" :row="row" :index="index">
<td v-for="(column, i) in columns" :class="getDataStyle(i, 'td')">
<td v-for="(column, i) in columns" :class="getDataStyle(i, 'td')" v-if="!column.hidden">
<span v-if="!column.html">{{ collectFormatted(row, column) }}</span>
<span v-if="column.html" v-html="collect(row, column.field)"></span>
</td>
Expand Down Expand Up @@ -69,11 +70,11 @@
<div class="pagination-controls pull-right">
<a href="javascript:undefined" class="page-btn" @click.prevent.stop="previousPage" tabindex="0">
<span class="chevron left"></span>
<span class="label">{{prevText}}</span>
<span>{{prevText}}</span>
</a>
<div class="info">{{paginatedInfo}}</div>
<a href="javascript:undefined" class="page-btn" @click.prevent.stop="nextPage" tabindex="0">
<span class="label">{{nextText}}</span>
<span>{{nextText}}</span>
<span class="chevron right"></span>
</a>
</div>
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 637bc58

Please sign in to comment.