Tabulator: How to get row Id on cellClick

Created on 18 Jan 2018  路  11Comments  路  Source: olifolkerd/tabulator

i would like to know the row id on cellClick ,because each cell have different functionalities but their database is related to their row id. So is there any way to do this?

Question - Ask On Stack Overflow

Most helpful comment

$("#example-table").tabulator({
    columns:[
        {id:1, title:"Name", field:"name", sorter:"string", width:200, editor:true},
 ],


{title:"Name", field:"name", cellClick:function(e, cell){
        //e - the click event object
        //cell - cell component
       var row = cell.getRow()
       var rowIndex = row.getIndex();
    },
}
});

Something like this?

All 11 comments

$("#example-table").tabulator({
    columns:[
        {id:1, title:"Name", field:"name", sorter:"string", width:200, editor:true},
 ],


{title:"Name", field:"name", cellClick:function(e, cell){
        //e - the click event object
        //cell - cell component
       var row = cell.getRow()
       var rowIndex = row.getIndex();
    },
}
});

Something like this?

I'd like to re-open the issue since I just done what the guys said and I get undefined
Screenshot 2019-10-24 at 12 34 08 PM
Using cellClick

Screenshot 2019-10-24 at 12 42 16 PM

@olifolkerd

@ShinobiWPS

Without seeing where that function is called from it is impossible to offer you help, it is likely that your setSelectedCell function is being called without the cell component being passed into it.

Oli

that's all
Screenshot 2019-10-24 at 2 08 23 PM

the arguments are from Tabulator, i'm not doing anything else like manipulating or filtering arguments,so if something is missing, is a library bug or something

The cell click function is working exactly as expected when I use it. Please confirm which version of Tabulator u are using.

Also please create a JS Fiddle so we can see how your table is configured. As I mentioned it is impossible to diagnose your issue without the context in which it is being used.

Cheers

Oli

Thanks that was very helpful,

The reason you are getting undefined is because you have no id property defined on your row data which is what the getIndex function returns, (or whatever field you have specified in the index setup option)

If you want to get the position of the row in the table, ie the number of rows from the top of the table then you need to call the getPosition function on the row component.

If in future you could provide a JS Fiddle or a bit more information about how you are using your table when you first post it will make it easier for us to help you

Cheers

Oli :)

thank you @olifolkerd ,that was enlightning!
Leaving everything here for the the next @me having same issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AndrewHutcheson picture AndrewHutcheson  路  3Comments

sphynx79 picture sphynx79  路  3Comments

Manbec picture Manbec  路  3Comments

soo1025 picture soo1025  路  3Comments

Honiah picture Honiah  路  3Comments