Select a cell in data table

Hi,

I’m very new to Javascript. How can I select value of data table? If I can do it, I can create second ColumnDataSource and use it to update my plots.

Could you please help? (when I click a row on Data Table, I want my plots to be updated due to the value of the cell [row, 7] “column number=7” )

Regards,
Fatih

I have an ugly way to get the row and column of a selected cell from data tables, and it doesn’t work when the table is sorted

from bokeh.io import show

from bokeh.layouts import widgetbox

from bokeh.models import ColumnDataSource, CustomJS

from bokeh.models.widgets import DataTable,TableColumn

column_list = [‘col1’,‘col2’,‘col3’]

source = ColumnDataSource(data = {key:range(10) for key in column_list})

columns = [TableColumn(field=col, title=col) for col in column_list]

data_table = DataTable(source=source, columns=columns, width=400, height=280,selectable=True)

source_code = “”"

var grid = document.getElementsByClassName(‘grid-canvas’)[0].children;

var row = ‘’;

var col = ‘’;

for (var i=0,max=grid.length;i<max;i++){

if (grid[i].outerHTML.includes('active')){

	row=i;

	for (var j=0,jmax=grid[i].children.length;j<jmax;j++){

		if(grid[i].children[j].outerHTML.includes('active')){col=j}

	}

}

}

console.log(‘row’,row);

console.log(‘col’,col);

cb_obj.selected[‘1d’].indices = ;

“”"

source.callback = CustomJS(code= source_code)

show(widgetbox(data_table))

``

Thank you for your help Sebastien.
I did in an easy way. I give the snippet code below and shortly explain, maybe someone else might need it later.

def table_select_callback(attr, old, new):

selected_row = new['1d']['indices'][0]

global valueMAC

valueMAC = table_source.data['con_sta'][selected_row]

table_source.on_change(‘selected’, table_select_callback)

table_source is a ColumnDataSource tied to a data table. When any cell is clicked on the data table, the row is selected then con_sta attribute is assigned to the global variable “valueMAC”. con_sta is the name of column. My use case: I set it as global variable so I am able to use it to fetch data from SQL by filtering for my plots for a selected specific device.

26 Temmuz 2017 Çarşamba 19:31:28 UTC+2 tarihinde Sébastien Roche yazdı:

···

I have an ugly way to get the row and column of a selected cell from data tables, and it doesn’t work when the table is sorted

from bokeh.io import show

from bokeh.layouts import widgetbox

from bokeh.models import ColumnDataSource, CustomJS

from bokeh.models.widgets import DataTable,TableColumn

column_list = [‘col1’,‘col2’,‘col3’]

source = ColumnDataSource(data = {key:range(10) for key in column_list})

columns = [TableColumn(field=col, title=col) for col in column_list]

data_table = DataTable(source=source, columns=columns, width=400, height=280,selectable=True)

source_code = “”"

var grid = document.getElementsByClassName(‘grid-canvas’)[0].children;

var row = ‘’;

var col = ‘’;

for (var i=0,max=grid.length;i<max;i++){

if (grid[i].outerHTML.includes(‘active’)){

  row=i;
  for (var j=0,jmax=grid[i].children.length;j<jmax;j++){
  	if(grid[i].children[j].outerHTML.includes('active')){col=j}
  }

}

}

console.log(‘row’,row);

console.log(‘col’,col);

cb_obj.selected[‘1d’].indices = ;

“”"

source.callback = CustomJS(code= source_code)

show(widgetbox(data_table))

``

Thanks a bunch Fatih! This works great for me!

Only thing I had to change was table_source.data[‘con_sta’][selected_row] to table_source.data[‘con_sta’].iloc[selected_row] because I pass pandas dataframe through source :slight_smile:

You’re welcome Joris! I’m glad to hear that.
Thank you for sharing your solution as well :slight_smile:

3 Ağustos 2017 Perşembe 11:40:49 UTC+2 tarihinde Joris Bekkers yazdı:

···

Thanks a bunch Fatih! This works great for me!

Only thing I had to change was table_source.data[‘con_sta’][selected_row] to table_source.data[‘con_sta’].iloc[selected_row] because I pass pandas dataframe through source :slight_smile:

Hi Sebastien,

Is there any alternative to do the same using Python callback instead of javascript?

I need to call different Python functions for column 1 and column 2…

from random import randint

from datetime import date

from bokeh.models import ColumnDataSource, TableColumn, DateFormatter, DataTable

from bokeh.layouts import column

from bokeh.models.widgets import TextInput, Button

from bokeh.client import push_session

from bokeh.plotting import curdoc

data = dict(dates = [date(2014, 3, i + 1) for i in range(10)], downloads = [randint(0, 100) for i in range(10)], identities = [‘id_’ + str(x) for x in range(10)])

source = ColumnDataSource(data)

columns = [TableColumn(field = “dates”, title = “Date”, formatter = DateFormatter()), TableColumn(field = “downloads”, title = “Downloads”)]

data_table = DataTable(source = source, columns = columns, width = 400, height = 280, editable = True)

text_row = TextInput(value = None, title = “Row index:”)

text_column = TextInput(value = None, title = “Column Index:”)

text_date = TextInput(value = None, title = “Date:”)

text_downloads = TextInput(value = None, title = “Downloads:”)

def function_source(attr, old, new):

try:

    selected_index = source.selected["1d"]["indices"][0]

    text_row.value = str(selected_index)

    text_date.value = str(source.data["dates"][selected_index])

    text_downloads.value = str(source.data["downloads"][selected_index])

except IndexError:

    pass

source.on_change(‘selected’, function_source)

session = push_session(document = curdoc())

curdoc().add_root(column(data_table, text_row, text_column, text_date, text_downloads))

session.show()

session.loop_until_closed()

``

···

On Thursday, August 3, 2017 at 10:16:51 AM UTC+2, Fatih Kılıç wrote:

Thank you for your help Sebastien.
I did in an easy way. I give the snippet code below and shortly explain, maybe someone else might need it later.

def table_select_callback(attr, old, new):

selected_row = new[‘1d’][‘indices’][0]

global valueMAC

valueMAC = table_source.data[‘con_sta’][selected_row]

table_source.on_change(‘selected’, table_select_callback)

table_source is a ColumnDataSource tied to a data table. When any cell is clicked on the data table, the row is selected then con_sta attribute is assigned to the global variable “valueMAC”. con_sta is the name of column. My use case: I set it as global variable so I am able to use it to fetch data from SQL by filtering for my plots for a selected specific device.

26 Temmuz 2017 Çarşamba 19:31:28 UTC+2 tarihinde Sébastien Roche yazdı:

I have an ugly way to get the row and column of a selected cell from data tables, and it doesn’t work when the table is sorted

from bokeh.io import show

from bokeh.layouts import widgetbox

from bokeh.models import ColumnDataSource, CustomJS

from bokeh.models.widgets import DataTable,TableColumn

column_list = [‘col1’,‘col2’,‘col3’]

source = ColumnDataSource(data = {key:range(10) for key in column_list})

columns = [TableColumn(field=col, title=col) for col in column_list]

data_table = DataTable(source=source, columns=columns, width=400, height=280,selectable=True)

source_code = “”"

var grid = document.getElementsByClassName(‘grid-canvas’)[0].children;

var row = ‘’;

var col = ‘’;

for (var i=0,max=grid.length;i<max;i++){

if (grid[i].outerHTML.includes('active')){
  row=i;
  for (var j=0,jmax=grid[i].children.length;j<jmax;j++){
  	if(grid[i].children[j].outerHTML.includes('active')){col=j}
  }
}

}

console.log(‘row’,row);

console.log(‘col’,col);

cb_obj.selected[‘1d’].indices = ;

“”"

source.callback = CustomJS(code= source_code)

show(widgetbox(data_table))

``

I have not tested that bit I guess In the JS callback you could update another ColumnDataSource with the column and row values, then in your python callback you could read that source to determine which function to use.

···

Le vendredi 15 décembre 2017 17:53:32 UTC-5, Tony Halik a écrit :

Hi Sebastien,

Is there any alternative to do the same using Python callback instead of javascript?

I need to call different Python functions for column 1 and column 2…

from random import randint

from datetime import date

from bokeh.models import ColumnDataSource, TableColumn, DateFormatter, DataTable

from bokeh.layouts import column

from bokeh.models.widgets import TextInput, Button

from bokeh.client import push_session

from bokeh.plotting import curdoc

data = dict(dates = [date(2014, 3, i + 1) for i in range(10)], downloads = [randint(0, 100) for i in range(10)], identities = [‘id_’ + str(x) for x in range(10)])

source = ColumnDataSource(data)

columns = [TableColumn(field = “dates”, title = “Date”, formatter = DateFormatter()), TableColumn(field = “downloads”, title = “Downloads”)]

data_table = DataTable(source = source, columns = columns, width = 400, height = 280, editable = True)

text_row = TextInput(value = None, title = “Row index:”)

text_column = TextInput(value = None, title = “Column Index:”)

text_date = TextInput(value = None, title = “Date:”)

text_downloads = TextInput(value = None, title = “Downloads:”)

def function_source(attr, old, new):

try:
    selected_index = source.selected["1d"]["indices"][0]
    text_row.value = str(selected_index)
    text_date.value = str(source.data["dates"][selected_index])
    text_downloads.value = str(source.data["downloads"][selected_index])
except IndexError:
    pass

source.on_change(‘selected’, function_source)

session = push_session(document = curdoc())

curdoc().add_root(column(data_table, text_row, text_column, text_date, text_downloads))

session.show()

session.loop_until_closed()

``

On Thursday, August 3, 2017 at 10:16:51 AM UTC+2, Fatih Kılıç wrote:

Thank you for your help Sebastien.
I did in an easy way. I give the snippet code below and shortly explain, maybe someone else might need it later.

def table_select_callback(attr, old, new):

selected_row = new['1d']['indices'][0]

global valueMAC

valueMAC = table_source.data['con_sta'][selected_row]

table_source.on_change(‘selected’, table_select_callback)

table_source is a ColumnDataSource tied to a data table. When any cell is clicked on the data table, the row is selected then con_sta attribute is assigned to the global variable “valueMAC”. con_sta is the name of column. My use case: I set it as global variable so I am able to use it to fetch data from SQL by filtering for my plots for a selected specific device.

26 Temmuz 2017 Çarşamba 19:31:28 UTC+2 tarihinde Sébastien Roche yazdı:

I have an ugly way to get the row and column of a selected cell from data tables, and it doesn’t work when the table is sorted

from bokeh.io import show

from bokeh.layouts import widgetbox

from bokeh.models import ColumnDataSource, CustomJS

from bokeh.models.widgets import DataTable,TableColumn

column_list = [‘col1’,‘col2’,‘col3’]

source = ColumnDataSource(data = {key:range(10) for key in column_list})

columns = [TableColumn(field=col, title=col) for col in column_list]

data_table = DataTable(source=source, columns=columns, width=400, height=280,selectable=True)

source_code = “”"

var grid = document.getElementsByClassName(‘grid-canvas’)[0].children;

var row = ‘’;

var col = ‘’;

for (var i=0,max=grid.length;i<max;i++){

if (grid[i].outerHTML.includes('active')){
  row=i;
  for (var j=0,jmax=grid[i].children.length;j<jmax;j++){
  	if(grid[i].children[j].outerHTML.includes('active')){col=j}
  }
}

}

console.log(‘row’,row);

console.log(‘col’,col);

cb_obj.selected[‘1d’].indices = ;

“”"

source.callback = CustomJS(code= source_code)

show(widgetbox(data_table))

``

Thanks!
This is what I have:

from random import randint

from datetime import date

from bokeh.models import ColumnDataSource, TableColumn, DateFormatter, DataTable, CustomJS

from bokeh.layouts import column

from bokeh.models.widgets import TextInput

from bokeh.client import push_session

from bokeh.plotting import curdoc

selected_source = ColumnDataSource({‘column’: [-1], ‘row’: [-1]})

source = ColumnDataSource(dict(dates = [date(2014, 3, i + 1) for i in range(10)], downloads = [randint(0, 100) for i in range(10)]))

columns = [TableColumn(field = “dates”, title = “Date”, formatter = DateFormatter()), TableColumn(field = “downloads”, title = “Downloads”)]

data_table = DataTable(source = source, columns = columns, width = 400, height = 280, editable = True)

text_row = TextInput(value = None, title = “Row index:”)

text_column = TextInput(value = None, title = “Column Index:”)

text_date = TextInput(value = None, title = “Date:”)

text_downloads = TextInput(value = None, title = “Downloads:”)

def table_click(row, column):

print ('Row %s Column %s clicked' % (row, column))

source_code = “”"

var grid = document.getElementsByClassName(‘grid-canvas’)[0].children;

var row = ‘’;

var col = ‘’;

for (var i=0,max=grid.length;i<max;i++)

{

if (grid[i].outerHTML.includes('active'))

{

    row=i;

    for (var j = 0, jmax = grid[i].children.length; j < jmax; j++)

    {

        if(grid[i].children[j].outerHTML.includes('active')) 

            { col = j }

    }

}

}

new_data = {‘column’: [col], ‘row’: [row]};

source.data = new_data

“”"

source.callback = CustomJS(args = dict(source = selected_source), code = source_code)

def function_source(attr, old, new):

try:

    selected_index = source.selected["1d"]["indices"][0]

    text_row.value = str(selected_source.data["row"][0])

    text_date.value = str(source.data["dates"][selected_index])

    text_downloads.value = str(source.data["downloads"][selected_index])

    text_column.value = str(selected_source.data["column"][0])

    source.selected.update({"0d":{"indices": []}, "1d":{"indices":[]}, "2d":{"indices":[]}})

    table_click(selected_source.data["row"][0], selected_source.data["column"][0])

except IndexError:

    pass

source.on_change(‘selected’, function_source)

session = push_session(document = curdoc())

curdoc().add_root(column(data_table, text_row, text_column, text_date, text_downloads))

session.show()

session.loop_until_closed()

``

···

On Monday, December 18, 2017 at 8:31:16 PM UTC+1, Sébastien Roche wrote:

I have not tested that bit I guess In the JS callback you could update another ColumnDataSource with the column and row values, then in your python callback you could read that source to determine which function to use.

Le vendredi 15 décembre 2017 17:53:32 UTC-5, Tony Halik a écrit :

Hi Sebastien,

Is there any alternative to do the same using Python callback instead of javascript?

I need to call different Python functions for column 1 and column 2…

from random import randint

from datetime import date

from bokeh.models import ColumnDataSource, TableColumn, DateFormatter, DataTable

from bokeh.layouts import column

from bokeh.models.widgets import TextInput, Button

from bokeh.client import push_session

from bokeh.plotting import curdoc

data = dict(dates = [date(2014, 3, i + 1) for i in range(10)], downloads = [randint(0, 100) for i in range(10)], identities = [‘id_’ + str(x) for x in range(10)])

source = ColumnDataSource(data)

columns = [TableColumn(field = “dates”, title = “Date”, formatter = DateFormatter()), TableColumn(field = “downloads”, title = “Downloads”)]

data_table = DataTable(source = source, columns = columns, width = 400, height = 280, editable = True)

text_row = TextInput(value = None, title = “Row index:”)

text_column = TextInput(value = None, title = “Column Index:”)

text_date = TextInput(value = None, title = “Date:”)

text_downloads = TextInput(value = None, title = “Downloads:”)

def function_source(attr, old, new):

try:
    selected_index = source.selected["1d"]["indices"][0]
    text_row.value = str(selected_index)
    text_date.value = str(source.data["dates"][selected_index])
    text_downloads.value = str(source.data["downloads"][selected_index])
except IndexError:
    pass

source.on_change(‘selected’, function_source)

session = push_session(document = curdoc())

curdoc().add_root(column(data_table, text_row, text_column, text_date, text_downloads))

session.show()

session.loop_until_closed()

``

On Thursday, August 3, 2017 at 10:16:51 AM UTC+2, Fatih Kılıç wrote:

Thank you for your help Sebastien.
I did in an easy way. I give the snippet code below and shortly explain, maybe someone else might need it later.

def table_select_callback(attr, old, new):

selected_row = new['1d']['indices'][0]

global valueMAC

valueMAC = table_source.data['con_sta'][selected_row]

table_source.on_change(‘selected’, table_select_callback)

table_source is a ColumnDataSource tied to a data table. When any cell is clicked on the data table, the row is selected then con_sta attribute is assigned to the global variable “valueMAC”. con_sta is the name of column. My use case: I set it as global variable so I am able to use it to fetch data from SQL by filtering for my plots for a selected specific device.

26 Temmuz 2017 Çarşamba 19:31:28 UTC+2 tarihinde Sébastien Roche yazdı:

I have an ugly way to get the row and column of a selected cell from data tables, and it doesn’t work when the table is sorted

from bokeh.io import show

from bokeh.layouts import widgetbox

from bokeh.models import ColumnDataSource, CustomJS

from bokeh.models.widgets import DataTable,TableColumn

column_list = [‘col1’,‘col2’,‘col3’]

source = ColumnDataSource(data = {key:range(10) for key in column_list})

columns = [TableColumn(field=col, title=col) for col in column_list]

data_table = DataTable(source=source, columns=columns, width=400, height=280,selectable=True)

source_code = “”"

var grid = document.getElementsByClassName(‘grid-canvas’)[0].children;

var row = ‘’;

var col = ‘’;

for (var i=0,max=grid.length;i<max;i++){

if (grid[i].outerHTML.includes('active')){
  row=i;
  for (var j=0,jmax=grid[i].children.length;j<jmax;j++){
  	if(grid[i].children[j].outerHTML.includes('active')){col=j}
  }
}

}

console.log(‘row’,row);

console.log(‘col’,col);

cb_obj.selected[‘1d’].indices = ;

“”"

source.callback = CustomJS(code= source_code)

show(widgetbox(data_table))

``

The only problem is that the second click on the same table cell is not detected.
Is there any solution for this?

···

On Tuesday, December 19, 2017 at 12:51:53 AM UTC+1, Tony Halik wrote:

Thanks!
This is what I have:

from random import randint

from datetime import date

from bokeh.models import ColumnDataSource, TableColumn, DateFormatter, DataTable, CustomJS

from bokeh.layouts import column

from bokeh.models.widgets import TextInput

from bokeh.client import push_session

from bokeh.plotting import curdoc

selected_source = ColumnDataSource({‘column’: [-1], ‘row’: [-1]})

source = ColumnDataSource(dict(dates = [date(2014, 3, i + 1) for i in range(10)], downloads = [randint(0, 100) for i in range(10)]))

columns = [TableColumn(field = “dates”, title = “Date”, formatter = DateFormatter()), TableColumn(field = “downloads”, title = “Downloads”)]

data_table = DataTable(source = source, columns = columns, width = 400, height = 280, editable = True)

text_row = TextInput(value = None, title = “Row index:”)

text_column = TextInput(value = None, title = “Column Index:”)

text_date = TextInput(value = None, title = “Date:”)

text_downloads = TextInput(value = None, title = “Downloads:”)

def table_click(row, column):

print ('Row %s Column %s clicked' % (row, column))

source_code = “”"

var grid = document.getElementsByClassName(‘grid-canvas’)[0].children;

var row = ‘’;

var col = ‘’;

for (var i=0,max=grid.length;i<max;i++)

{

if (grid[i].outerHTML.includes('active'))
{
    row=i;
    for (var j = 0, jmax = grid[i].children.length; j < jmax; j++)
    {
        if(grid[i].children[j].outerHTML.includes('active')) 
            { col = j }
    }
}

}

new_data = {‘column’: [col], ‘row’: [row]};

source.data = new_data

“”"

source.callback = CustomJS(args = dict(source = selected_source), code = source_code)

def function_source(attr, old, new):

try:
    selected_index = source.selected["1d"]["indices"][0]
    text_row.value = str(selected_source.data["row"][0])
    text_date.value = str(source.data["dates"][selected_index])
    text_downloads.value = str(source.data["downloads"][selected_index])
    text_column.value = str(selected_source.data["column"][0])
    source.selected.update({"0d":{"indices": []}, "1d":{"indices":[]}, "2d":{"indices":[]}})
    table_click(selected_source.data["row"][0], selected_source.data["column"][0])
except IndexError:
    pass

source.on_change(‘selected’, function_source)

session = push_session(document = curdoc())

curdoc().add_root(column(data_table, text_row, text_column, text_date, text_downloads))

session.show()

session.loop_until_closed()

``

On Monday, December 18, 2017 at 8:31:16 PM UTC+1, Sébastien Roche wrote:

I have not tested that bit I guess In the JS callback you could update another ColumnDataSource with the column and row values, then in your python callback you could read that source to determine which function to use.

Le vendredi 15 décembre 2017 17:53:32 UTC-5, Tony Halik a écrit :

Hi Sebastien,

Is there any alternative to do the same using Python callback instead of javascript?

I need to call different Python functions for column 1 and column 2…

from random import randint

from datetime import date

from bokeh.models import ColumnDataSource, TableColumn, DateFormatter, DataTable

from bokeh.layouts import column

from bokeh.models.widgets import TextInput, Button

from bokeh.client import push_session

from bokeh.plotting import curdoc

data = dict(dates = [date(2014, 3, i + 1) for i in range(10)], downloads = [randint(0, 100) for i in range(10)], identities = [‘id_’ + str(x) for x in range(10)])

source = ColumnDataSource(data)

columns = [TableColumn(field = “dates”, title = “Date”, formatter = DateFormatter()), TableColumn(field = “downloads”, title = “Downloads”)]

data_table = DataTable(source = source, columns = columns, width = 400, height = 280, editable = True)

text_row = TextInput(value = None, title = “Row index:”)

text_column = TextInput(value = None, title = “Column Index:”)

text_date = TextInput(value = None, title = “Date:”)

text_downloads = TextInput(value = None, title = “Downloads:”)

def function_source(attr, old, new):

try:
    selected_index = source.selected["1d"]["indices"][0]
    text_row.value = str(selected_index)
    text_date.value = str(source.data["dates"][selected_index])
    text_downloads.value = str(source.data["downloads"][selected_index])
except IndexError:
    pass

source.on_change(‘selected’, function_source)

session = push_session(document = curdoc())

curdoc().add_root(column(data_table, text_row, text_column, text_date, text_downloads))

session.show()

session.loop_until_closed()

``

On Thursday, August 3, 2017 at 10:16:51 AM UTC+2, Fatih Kılıç wrote:

Thank you for your help Sebastien.
I did in an easy way. I give the snippet code below and shortly explain, maybe someone else might need it later.

def table_select_callback(attr, old, new):

selected_row = new['1d']['indices'][0]

global valueMAC

valueMAC = table_source.data['con_sta'][selected_row]

table_source.on_change(‘selected’, table_select_callback)

table_source is a ColumnDataSource tied to a data table. When any cell is clicked on the data table, the row is selected then con_sta attribute is assigned to the global variable “valueMAC”. con_sta is the name of column. My use case: I set it as global variable so I am able to use it to fetch data from SQL by filtering for my plots for a selected specific device.

26 Temmuz 2017 Çarşamba 19:31:28 UTC+2 tarihinde Sébastien Roche yazdı:

I have an ugly way to get the row and column of a selected cell from data tables, and it doesn’t work when the table is sorted

from bokeh.io import show

from bokeh.layouts import widgetbox

from bokeh.models import ColumnDataSource, CustomJS

from bokeh.models.widgets import DataTable,TableColumn

column_list = [‘col1’,‘col2’,‘col3’]

source = ColumnDataSource(data = {key:range(10) for key in column_list})

columns = [TableColumn(field=col, title=col) for col in column_list]

data_table = DataTable(source=source, columns=columns, width=400, height=280,selectable=True)

source_code = “”"

var grid = document.getElementsByClassName(‘grid-canvas’)[0].children;

var row = ‘’;

var col = ‘’;

for (var i=0,max=grid.length;i<max;i++){

if (grid[i].outerHTML.includes('active')){
  row=i;
  for (var j=0,jmax=grid[i].children.length;j<jmax;j++){
  	if(grid[i].children[j].outerHTML.includes('active')){col=j}
  }
}

}

console.log(‘row’,row);

console.log(‘col’,col);

cb_obj.selected[‘1d’].indices = ;

“”"

source.callback = CustomJS(code= source_code)

show(widgetbox(data_table))

``

It’s because it’s a callback that triggers when the ‘selected’ attribute of the table source is changed, if you click twice on the same cell then the callback will not trigger the second time.
You can fix that by resetting the selected attribute of the source at the end of the callback

That’s why in my code I have

cb_obj.selected[‘1d’].indices = ;

``

at the end of the callback

Yes. But clicking twice on the same cell in your example also doesn’t work.
In my Python callback in the code above I was trying to reset all indices by doing:

source.selected.update({“0d”:{“indices”: }, “1d”:{“indices”:}, “2d”:{“indices”:}})

``

but it doesn’t work…

···

On Thursday, December 28, 2017 at 5:39:26 PM UTC+1, Sébastien Roche wrote:

It’s because it’s a callback that triggers when the ‘selected’ attribute of the table source is changed, if you click twice on the same cell then the callback will not trigger the second time.
You can fix that by resetting the selected attribute of the source at the end of the callback

That’s why in my code I have

cb_obj.selected[‘1d’].indices = ;

``

at the end of the callback

My example still works fine for me with bokeh 0.12.10 (didn’t test newer versions) I can click on the same cell several times and it will keep printing the row and column in the console.

···

Le jeudi 18 janvier 2018 12:03:44 UTC-5, Tony Halik a écrit :

Yes. But clicking twice on the same cell in your example also doesn’t work.
In my Python callback in the code above I was trying to reset all indices by doing:

source.selected.update({“0d”:{“indices”: }, “1d”:{“indices”:}, “2d”:{“indices”:}})

``

but it doesn’t work…

On Thursday, December 28, 2017 at 5:39:26 PM UTC+1, Sébastien Roche wrote:

It’s because it’s a callback that triggers when the ‘selected’ attribute of the table source is changed, if you click twice on the same cell then the callback will not trigger the second time.
You can fix that by resetting the selected attribute of the source at the end of the callback

That’s why in my code I have

cb_obj.selected[‘1d’].indices = ;

``

at the end of the callback

OK. Thanks.
I’m still using 0.12.6…

···

On Monday, January 22, 2018 at 8:27:25 PM UTC+1, Sébastien Roche wrote:

My example still works fine for me with bokeh 0.12.10 (didn’t test newer versions) I can click on the same cell several times and it will keep printing the row and column in the console.

Le jeudi 18 janvier 2018 12:03:44 UTC-5, Tony Halik a écrit :

Yes. But clicking twice on the same cell in your example also doesn’t work.
In my Python callback in the code above I was trying to reset all indices by doing:

source.selected.update({“0d”:{“indices”: }, “1d”:{“indices”:}, “2d”:{“indices”:}})

``

but it doesn’t work…

On Thursday, December 28, 2017 at 5:39:26 PM UTC+1, Sébastien Roche wrote:

It’s because it’s a callback that triggers when the ‘selected’ attribute of the table source is changed, if you click twice on the same cell then the callback will not trigger the second time.
You can fix that by resetting the selected attribute of the source at the end of the callback

That’s why in my code I have

cb_obj.selected[‘1d’].indices = ;

``

at the end of the callback