title: Refreshing Bokeh DataTable through Selection of Plots
body: <p>I am trying to update Bokeh DataTable by selecting a plot.Not sure why it's not getting updated?In the code below,source_devon is ColumnDataSource for the plot- I wanted Datatable to get updated when we select a particular portion.Currently DataTable is created(initialization),but it doesn't changes on selection</p>
  
  <pre><code>from bokeh.io import curdoc
  from bokeh.layouts import layout,row
  from bokeh.models import CDSView,HoverTool,GroupFilter,ColumnDataSource,Button,Select,TextInput,Slider,DataTable,TableColumn,DateFormatter,LinearAxis,Range1d,CustomJS,Rect
  from bokeh.plotting import figure,output_file,show
  from datetime import datetime, timedelta
  from bokeh.client import push_session
  import pandas as pd
  import numpy as np
  
  
  
  TOOLS='pan,wheel_zoom,box_zoom,reset,tap,save,lasso_select,xbox_select'
  
  # Select widget
  ccy_options = ['AUDUSD', 'USDJPY']
  menu = Select(options=['AUDUSD','USDJPY'], value='AUDUSD')
  slider = Slider(start=-1000, end=10000, step=1000, value=-1000, title='Volume Cutoff')
  
  
  # Function to get Order/Trade/Price Datasets
  def get_combined_dataset(src,name):
  df = src[(src.CCYPAIR == name)].copy()
  return ColumnDataSource(data=df)
  
  # Function to Make Plots
  def make_plot(source_order):
  x  = 'DATE'
  y  = 'PRICE'
  y1 = 'Volume'
  size = 10
  alpha = 0.5
  hover = HoverTool(
  tooltips = [
      ('OrderId', '@ORDER_ID_108'),
      ('Volume', '@Volume'),
      ('Price', '@PRICE')
      ]
  )
  view1 = CDSView(source=source_order, filters=[GroupFilter(column_name='TYPE',group='ORDER'),GroupFilter(column_name='SIDE',group='B')])
  view2 = CDSView(source=source_order, filters=[GroupFilter(column_name='TYPE',group='ORDER'),GroupFilter(column_name='SIDE',group='S')])
  view3 = CDSView(source=source_order, filters=[GroupFilter(column_name='TYPE',group='TRADE'),GroupFilter(column_name='SIDE',group='B')])
  view4 = CDSView(source=source_order, filters=[GroupFilter(column_name='TYPE',group='TRADE'),GroupFilter(column_name='SIDE',group='S')])
  view5 = CDSView(source=source_order, filters=[GroupFilter(column_name='TYPE',group='DevonTrade')])
  view6 = CDSView(source=source_order, filters=[GroupFilter(column_name='TYPE',group='Prices')])
  plot2 = figure(plot_width=1000, plot_height=300, tools=[hover, TOOLS], 
     title='Agg. Position Snapshot for Devon',
     x_axis_label='Date', y_axis_label='Price',x_axis_type="datetime")
  
  plot = figure(plot_width=1000,    plot_height=300,tools=TOOLS,x_axis_type="datetime",title='Order/Execution Snapshot with Price Levels')
  plot.circle(x=x,y=y,source=source_order,view=view1,alpha=0.6,color='blue')
  plot.circle(x=x,y=y,source=source_order,view=view2,alpha=0.6,color='red')
  plot.triangle(x=x,y=y,source=source_order,view=view3,alpha=0.6,color='blue')
  plot.triangle(x=x,y=y,source=source_order,view=view4,alpha=0.6,color='red')
  plot.line(x=x,y=y,source=source_order,view=view6,color='green')
  plot2.line(x=x,y=y1,source=source_order,view=view5,color='blue')
  plot.legend.location = 'top_left'
  return plot,plot2
  
  def make_table(source):
  columns = [
  TableColumn(field='DATE', title="DATE", formatter=DateFormatter()),
  TableColumn(field='CCYPAIR', title="CCYPAIR"),
      TableColumn(field='SIDE', title="SIDE"),
      TableColumn(field='PRICE', title="PRICE"),
      TableColumn(field='TYPE', title="TYPE"),
      TableColumn(field='Volume', title="Volume"),
      TableColumn(field='ORDER_ID_108', title="ORDERID"),
  ]
  data_table = DataTable(source=source, columns=columns, width=1000, height=200)
  return data_table
  def update_plot(attrname, old, new):
  newccy = menu.value
  newvalue = slider.value
  src_data_table = get_combined_dataset(Combined,newccy)
  DisplayData.data.update(src_data_table.data)
  
  
  def update_plot(attrname, old, new):
  newccy = menu.value
  newvalue = slider.value
  src_data_table = get_combined_dataset(Combined,newccy)
  DisplayData.data.update(src_data_table.data)
  
  
  def selection_change(attrname, old, new):
  data =  get_all_dataset(Combined,menu.value)
  selected = DisplayData.selected['1d']['indices']
  if selected:
     data  = data.iloc[selected, :]
     update_datatable(data)
  
  def update_datatable(data):
  src_data_table = get_combined_dataset(data,menu.value)
  s2.data.update(src_data_table.data)
  
  # Input Files    
  date_today = datetime.now()
  days = pd.date_range(date_today, date_today + timedelta(5), freq='D')
  Combined1 = {'DATE': days,
   'CCYPAIR': ['USDJPY', 'USDJPY', 'USDJPY','USDJPY', 'USDJPY', 'USDJPY'],
   'SIDE' : ['B', 'B', 'B','B', 'B', 'B'],
   'PRICE': [100.00, 200.00, 300.00,100.00, 200.00, 300.00],
   'TYPE' : ['ORDER', 'ORDER', 'ORDER','DevonTrade', 'DevonTrade', 'DevonTrade'],
   'Volume': [100, 200, 300, 100, 200, 300],
   'ORDER_ID_108':  [111,222,333,111,222,333]
     }
  Combined = pd.DataFrame(Combined1)
  
  
  DisplayData =  get_combined_dataset(Combined,menu.value)
  plot,plot2 =  make_plot(DisplayData)
  menu.on_change('value', update_plot)
  plot.x_range = plot2.x_range
  
  s2 = ColumnDataSource(data=dict(DATE=[],CCYPAIR=[],SIDE=[],PRICE=[],TYPE=[],Volume=[],ORDER_ID_108=[]))
  
  columns = [
      TableColumn(field='DATE', title="DATE", formatter=DateFormatter()),
      TableColumn(field='CCYPAIR', title="CCYPAIR"),
      TableColumn(field='SIDE', title="SIDE"),
      TableColumn(field='PRICE', title="PRICE"),
      TableColumn(field='TYPE', title="TYPE"),
      TableColumn(field='Volume', title="Volume"),
      TableColumn(field='ORDER_ID_108', title="ORDER_ID_108")
  ]
  data_table = DataTable(source=s2,columns=columns,width=1000, height=200)
  
  
  
  layout = layout([menu],
              [plot],
              [plot2],
              [data_table])
  curdoc().add_root(layout)
  
  DisplayData.on_change('selected', selection_change)
  </code></pre>