Skip to content

Commit f4a7b78

Browse files
author
Yousef Sultan
committed
Fix more jank
Signed-off-by: Yousef Sultan <[email protected]>
1 parent 87a3097 commit f4a7b78

File tree

5 files changed

+48
-21
lines changed

5 files changed

+48
-21
lines changed

docs/css/app.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/js/app.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs_src/App.vue

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,30 @@ data() {
437437
/>
438438
</div>
439439
</div>
440+
<div id="loading" class="row scrollspy" style="margin-bottom: 0;">
441+
<div
442+
class="col s12 m8 offset-m1 xl11 offset-xl1 center-on-small-only"
443+
>
444+
<h3 class="header">
445+
Loading animation
446+
</h3>
447+
<p>Table with empty array of rows</p>
448+
<prism language="html">
449+
&lt;datatable
450+
title="Table with loading animation"
451+
:columns="tableColumns1"
452+
:rows="[]"
453+
:perPage="[3, 5, 10]"
454+
/&gt;
455+
</prism>
456+
<datatable
457+
title="Table with loading animation"
458+
:columns="tableColumns1"
459+
:rows="[]"
460+
:per-page="[3, 5, 10]"
461+
/>
462+
</div>
463+
</div>
440464
<div id="row-buttons" class="row scrollspy" style="margin-bottom: 0;">
441465
<div
442466
class="col s12 m8 offset-m1 xl11 offset-xl1 center-on-small-only"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-materialize-datatable",
3-
"version": "0.7.8",
3+
"version": "1.0.0",
44
"description": "Datatable for VueJS with Materialize",
55
"author": "Yousef Sultan <[email protected]>",
66
"private": false,

src/DataTable.vue

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@
3838
<div id="search-input-container">
3939
<label>
4040
<input id="search-input" type="search" class="form-control" :placeholder="lang['search_data']"
41-
:value="searchInput"
42-
@input="(e) => {searchInput = e.target.value}"
41+
v-model="searchInput"
4342
>
4443
</label>
4544
</div>
@@ -451,26 +450,37 @@
451450
},
452451
},
453452
453+
watch: {
454+
perPageOptions(newOptions, oldOptions) {
455+
// If defaultPerPage is provided and it's a valid option, set as current per page
456+
if (newOptions.indexOf(this.defaultPerPage) > -1) {
457+
this.currentPerPage = parseInt(this.defaultPerPage);
458+
} else {
459+
// Set current page to first value
460+
this.currentPerPage = newOptions[0];
461+
}
462+
},
463+
464+
searchInput(newSearchInput) {
465+
if (this.searching && this.serverSearch && this.serverSearchFunc)
466+
this.serverSearchFunc(newSearchInput);
467+
},
468+
},
469+
454470
computed: {
455471
perPageOptions() {
456472
let options = (Array.isArray(this.perPage) && this.perPage) || [10, 20, 30, 40, 50];
457473
458474
// Force numbers
459-
options = options.map( v => parseInt(v));
475+
options = options.map(v => parseInt(v));
460476
461-
// Set current page to first value
462-
this.currentPerPage = options[0];
463477
464478
// Sort options
465479
options.sort((a,b) => a - b);
466480
467481
// And add "All"
468482
options.push(-1);
469483
470-
// If defaultPerPage is provided and it's a valid option, set as current per page
471-
if (options.indexOf(this.defaultPerPage) > -1) {
472-
this.currentPerPage = parseInt(this.defaultPerPage);
473-
}
474484
475485
return options;
476486
},
@@ -499,13 +509,7 @@
499509
return (x < y ? -1 : (x > y ? 1 : 0)) * (this.sortType === 'desc' ? -1 : 1);
500510
});
501511
502-
if (this.searching && this.searchInput) {
503-
504-
if(this.serverSearch) {
505-
this.serverSearchFunc(this.searchInput);
506-
return;
507-
}
508-
512+
if (this.searching && !this.serverSearch && this.searchInput) {
509513
const searchConfig = { keys: this.columns.map(c => c.field) };
510514
511515
// Enable searching of numbers (non-string)
@@ -517,7 +521,7 @@
517521
return property;
518522
};
519523
520-
if(this.exactSearch){
524+
if (this.exactSearch) {
521525
//return only exact matches
522526
searchConfig.threshold = 0,
523527
searchConfig.distance = 0;
@@ -549,7 +553,6 @@
549553
mounted() {
550554
if (!(this.locale in locales))
551555
console.error(`vue-materialize-datable: Invalid locale '${this.locale}'`);
552-
this.currentPerPage = this.currentPerPage;
553556
this.sortColumn = this.initSortCol;
554557
},
555558
};

0 commit comments

Comments
 (0)