Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stop action events ? #51

Closed
malaschitz opened this issue Jul 21, 2016 · 3 comments
Closed

stop action events ? #51

malaschitz opened this issue Jul 21, 2016 · 3 comments

Comments

@malaschitz
Copy link

I have vue-table with item-actions and with detail-row too.

When I click on button (item-action) both events are called. At first item-action and next is open detail-row. Is possible stop detail-row event ?

@ratiw
Copy link
Owner

ratiw commented Jul 21, 2016

@malaschitz I actually overlook this issue. This will be fixed in the next release. Probably through a new event vuetable:cell-clicked or something. I will have to think about that.

The work around at the moment is to add a CSS class (e.g. detail-toggle) to a specific column and filtered it in vuetable:row-clicked event and use it to broadcast the event to toggle the detail row.

To demonstrate the work-around using this example

    var tableColumns = [
        {
            name: 'id',
            title: '',
            dataClass: 'detail-toggle center aligned',  // <--- add "detail-toggle" class
            callback: 'showDetailRow'
        },
    //...
    new Vue({
        el: '#app',
        //...
        methods: {
            //...
            // add "detail-toggle" class to the icon as well
            showDetailRow: function(value) {
                var icon = this.$refs.vuetable.isVisibleDetailRow(value) ? 'down' : 'right'
                return [
                    '<a class="show-detail-row">',
                        '<i class="detail-toggle chevron circle ' + icon + ' icon"></i>',
                    '</a>'
                ].join('')
            },
            //...
        },
        events: {
            //..
            'vuetable:row-clicked': function(data, event) {
                // filter the clicked target to see if it contains 'detail-toggle' class
                if (event.target.classList.contains('detail-toggle')) {
                    this.$broadcast('vuetable:toggle-detail', data.id)
                }
            },
            //...
        }
    })

In this example, the detail row will only gets toggled when the user clicks on the id column or the icon on that column, so clicking the action button or any other column will not have side effect.

@malaschitz
Copy link
Author

I suggest do not create a new event, but do not broadcast vuetable:row-clicked when is broadcast vuetable:action. Because I could broadcast event vuetable:row-clicked in my action when I will need it (but it is probably common).

Thanks for work around.

@ratiw
Copy link
Owner

ratiw commented Jul 22, 2016

I don't think that is possible. They are two separate events and are emitting independently from different DOM element.

Based on my initial test, a new event would solve this quite easily but I don't have time to look at it in more detail. It seems redundant, but I think each event would have its use when appropriate.

The good thing about the event model is that it is optional. You only register for the event(s) you're interested in and ignore everything else. The bad thing is you have to be more careful about the side effect.

ratiw added a commit that referenced this issue Jul 30, 2016
this is to fix the side effect of row-clicked event to toggle-detail event (#51) and also provide more fine grain click detection to table column.
ratiw added a commit that referenced this issue Aug 2, 2016
this is to fix the side effect of row-clicked event to toggle-detail event (#51) and also provide more fine grain click detection to table column.
@ratiw ratiw closed this as completed Aug 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants