Implements new functionality to make gridReturns more flexible:
adds, should_grid_return
and collect_grid_return
parameters to the grid call.
should_grid_return
is a JsCode
function that should return true (false) to allow (block) grid events subscribed via update_on.
example:
should_return = JsCode("""
function should_return({streamlitRerunEventTriggerName, eventData}){
return eventData && eventData.hasOwnProperty('finished') ? eventData.finished : false;
}
""")
collect_grid_return
is a JsCode
function that receives subscribed events data and process them, to produce the gridReturn.
example:
collect_return = JsCode("""
function collect_return({streamlitRerunEventTriggerName, eventData}){
let api = eventData.api;
//maps displayed columns objects into header names and returns this list as the grid return.
let colNames = api.getAllDisplayedColumns().map((c) => c.colDef.headerName);
return colNames
}
""")