I have another JavaScript question. I use a DataTable with the keyTable extension. This extension marks a single cell and you can navigate through the table with the arrow keys.
I want to read out, what cell is selected anytime. I think the easiest way is to do it with JavaScript, but I am an absolute beginner with JS, so you have to help me.
Code like
"table.on('key', function(e, datatable, key, cell, originalEvent){",
" var targetName = originalEvent.target.localName;",
" if(key == 13 && targetName == 'body'){",
" Shiny.setInputValue('Ausgaben_zelle_aenderung', cell.node());",
" }",
"});",
"table.on('key-focus', function(e, datatable, cell, originalEvent){",
" var targetName = originalEvent.target.localName;",
" var type = originalEvent.type;",
" if(type == 'keydown' && targetName == 'input'){",
" if([9,13,37,38,39,40].indexOf(originalEvent.keyCode) > -1){",
" Shiny.setInputValue('Ausgaben_zelle_aenderung', cell.node());",
" }",
" }",
"});"
gives me the information what cell is selected, while I'm in the editing mode. This works. I want to modify this code to get the cell information when I don't change the value. So I tried to adapt the code, but code like
"table.on('key', function(e, datatable, key, cell, originalEvent){",
" if([9,13,37,38,39,40].indexOf(key) > -1){",
" Shiny.setInputValue('test1', cell.node());",
" }",
"});"
is not working. Can you help me?
With best regards Chefkoch