Comments (12)
Added onRowClick
callback. See the options API.
from vue-tables.
Save the instance to a variable and replace this
with the variable name:
var vm = new Vue({
options:{
onRowClick:function(row){
vm.crew = row.FMemeber['CP'];
}
})
from vue-tables.
The table template doesn't have a click event bound to the row.
I suppose you can either fork the repo and add it to your version, or use JQuery.
I might add it in the future if it turns out to be a common request.
from vue-tables.
Just spent 10 mins looking for this feature in the docs too before discovering it here.
A +1 from me too thank you.
from vue-tables.
Thank you very much @matfish2 . That was much appreciated.
from vue-tables.
Ok I'm probably just being silly but how can I access the vue instance in the onRowClick callback.
At the moment when I try - this
becomes a window object, not the vue instance.
from vue-tables.
Ahh.. OK thank you.
from vue-tables.
@matfish2 thanks! :)
from vue-tables.
I have
var app = new Vue({
app is undefined within the onRowClick callback. The vue-table is nested within a component and this.$parent and this.$root are also undefined within the callback. Any clues?.
I note that $parnet is also undefined within a column template.
from vue-tables.
Can you paste the relevant HTML and JS?
from vue-tables.
app.js
require('spark-bootstrap');
require('./components/bootstrap');
var app = new Vue({
mixins: [require('spark')]
});
coponents/bootstrap.js
require('./../spark-components/bootstrap');
require('./../my-app-components/bootstrap');
require('./home');
my-app-components/bootstrap.js
var VueTables = require('vue-tables');
Vue.use(VueTables.server, {
compileTemplates: true,
highlightMatches: true,
filterByColumn: true,
texts: {
filter: "Search:",
limit:'Per Page:'
},
datepickerOptions: {
showDropdowns: true
}
});
Vue.use(VueTables.client, {
compileTemplates: true,
highlightMatches: true,
filterByColumn: true,
texts: {
filter: "Search:",
limit:'Per Page:'
},
datepickerOptions: {
showDropdowns: true
}
});
HTML (A Laravel Blade template)
<my-app-contacts
:user="user"
:contacts="contacts"
inline-template>
<div>
<div v-if="user">
<div id="people">
<v-server-table url="{{ route('api.v1.contacts.index') }}" :columns="columns" :options="options"></v-server-table>
</div>
</div>
</div>
</my-app-contacts>
contacts.js
module.exports = {
props: ['user'],
/**
* Load mixins for the component.
*/
mixins: [
require('./../../mixins/crud'),
require('./../../mixins/form'),
require('./../../mixins/list'),
require('./../../mixins/tabs')
],
/**
* The component's data.
*/
data() {
return {
hash: 'contacts',
columns: ['first_name','last_name','postal_address','postal_city','preferred_phone'
],
options: {
headings: {
first_name: 'First Name',
last_name: 'Last Name',
postal_address: 'Address',
postal_city: 'City',
preferred_phone: 'Phone',
actions: 'Actions'
},
templates: {
action: function (row) { return " <a href='javascript:void(0);' @click='$parent.editContact({row})'><i class='glyphicon glyphicon-edit'></i></a> <a href='javascript:void(0);' @click='$parent.approveContactDelete({row})'><i class='glyphicon glyphicon-erase'></i></a>"; }
},
columnsDisplay: {
postal_address: 'not_mobile',
actions: 'not_mobile'
},
onRowClick: function(row) {
$parent.view(row)
}
}
};
},
events: {
'vue-tables.loading': function (request) {
console.log('vue-tables loading');
},
'vue-tables.loaded': function (response) {
console.log('vue-tables loaded');
}
}
};
Note that in onRowClick and the action template this
, this.$parent
, $parent
and app
are all undefined. I also tried this.$dispatch but that is also undefined. The table seems to work in all other respects.
I can confirm that the vue-tables.loading
and vue-tables.loaded
events are being dispatched correctly form set-data.js. In set-data.js this
is, correctly, an instance of VServerTable.
In my onRowClick
function this
is just a plain Object with all of the v-server properties like columnsDisplay and compileTemplates.
from vue-tables.
When using a compiler like browserify
or webpack
the different modules are scoped and have no immediate access to other modules. You can either export your app
variable and import it into contacts.js
, or make contacts.js
a function that accepts your app
instance.
from vue-tables.
Related Issues (20)
- How to disable pagination component HOT 1
- Is there a way to freeze columns and make other columns scrollable? HOT 1
- Is there a way to center specific columns HOT 1
- click event on rows
- server side implementation HOT 1
- Q: Custom columns should not be show if not defined in columns attribute? HOT 1
- Laravel Implementation HOT 1
- Feature request - Column grouping
- Q : "pagination-info-template" no has data๏ผ HOT 1
- Use if-else to prevent data.json error
- Date format from server HOT 2
- Pagination from server HOT 1
- Unknown custom element: <v-server-table> - did you register the component correctly? HOT 4
- dateformate and server table HOT 1
- [Question] How to display a row index/running number column?
- V-Server-Table (vuetables2) HOT 1
- Display json filte HOT 1
- How to implemen server-side in Lumen? HOT 2
- DateRangepicker not showing HOT 1
- Missing ref owner context HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-tables.