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

Row index in onContextMenuItem event #7

Closed
Real-Gecko opened this issue Jan 20, 2016 · 2 comments
Closed

Row index in onContextMenuItem event #7

Real-Gecko opened this issue Jan 20, 2016 · 2 comments

Comments

@Real-Gecko
Copy link

Is it possible to add row index parameter to onContextMenuItem event?
I need something like this:

onContextMenuItem: function(row, index, $el) {
    if($el.data("item") == "update" {
        row.name = 'something';
        $table.bootstrapTable('updateRow', {
            index: index,
            row: row
        });
    }
}
@Real-Gecko
Copy link
Author

I found a solution

beforeContextMenuRow: function(e, row) {
    var index = ($(e.currentTarget).data("index"));
    $table.bootstrapTable('showContextMenu', { event: e } )
    .off('contextmenu-item.bs.table')
    .on('contextmenu-item.bs.table', function(ev, row, $el) {
        if($el.data("item") == "update") {
            row.name = "something";
            $('#list-table').bootstrapTable('updateRow', { 'index': index, 'row': row });
        }
    });
    return false;
}

However I'm not sure it does not have any overheads or caveats :)

@prograhammer
Copy link
Owner

Hmmm...You could use the updateByUniqueId method to accomplish this. But I do see it is good to have the index available. Let me look at the best way to provide the index and I'll tag a new release this weekend. Thanks for this recommendation. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants