Is there a way to retrieve the JavaScript variable name for a rhandsontable displayed in a Shiny application?

My project involves using the rhandsontable package to generate dynamic tables within a Shiny app.

I am in need of a solution that allows me to select certain cells programmatically, triggered by specific user interactions. Unfortunately, I have not been able to locate such functionality within the R-based rhandsontable wrapper.

In contrast, I have discovered that this selection capability is achievable with native Handsontable.js through the use of the selectCell() function. An illustrative example can be found below:

document.addEventListener("DOMContentLoaded", function() {
  var data = [
    ["", "Ford", "Volvo", "Toyota", "Honda"],
    ["2014", 10, 11, 12, 13],
    ["2015", 20, 11, 14, 13],
    ["2016", 30, 15, 12, 13]
  ];

  var container = document.getElementById('example1');
  var hot = new Handsontable(container, {
    data: data,
    minSpareRows: 1,
    rowHeaders: true,
    colHeaders: true,
    contextMenu: true
  });

  hot.selectCell(1, 0);
})
</style><!--  --><script src="https://docs.handsontable.com/0.15.0/scripts/jquery.min.js"></script><script src="https://docs.handsontable.com/0.15.0/bower_components/handsontable/dist/handsontable.full.js"></script><link type="text/css" rel="stylesheet" href="https://docs.handsontable.com/0.15.0/bower_components/handsontable/dist/handsontable.full.min.css">
<div id="example1" class="hot handsontable"></div>

http://jsfiddle.net/vz74zeqo/

So, by executing

shinyjs::runjs('hot.selectCell(1,0);')
, the desired outcome can be achieved seamlessly.

The key question now arises: how can one determine the variable name associated with the table when it is generated using the renderRHandsontable() function in Shiny? (as illustrated by the variable name hot in my case)

Your input would be greatly appreciated!

Regards,

Answer №1

This thread was a lifesaver: How to implement searching from a text input in a Handsontable within a Shiny app

By using

output$myTab = renderRHandsontable({rhandsontabe(faithful)})
to render rhandsontable, I was able to execute this JavaScript command successfully: getInstance():

HTMLWidgets.getInstance(myTab).hot.selectCell(0,1)

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Exclusive to Safari: Codesandbox is experiencing difficulties retrieving data from the localhost server

Would you mind helping me out with this technical issue I'm facing? For the server/API, I am using this link. As for the mock website, it can be found at this URL. The problem is that, in my code, I'm using axios to fetch data from the locally h ...

Exporting a node express app for chai-http can be done by creating a module

I have set up an express app with multiple endpoints and am currently using mocha, chai, and chai-http for testing. Everything was running smoothly until I added logic for a pooled mongo connection and started creating endpoints that rely on a DB connectio ...

Using Node.js to implement GET, POST, and DELETE functionalities

I have embarked on the journey of learning Node.js and I find myself in a state of confusion. Could you please guide me on how to construct effective HTTP requests for the following scenarios: 1) Retrieve all galleries from the gallerySchema using a GET ...

Adding an external JavaScript library file to a specific component in Angular 7 is a straightforward process. Let's walk through the

As a beginner in Angular framework, I've encountered an issue while working on creating a custom HTML template using Angular version 7. My template consists of various pages like home, about, product, etc. Specifically, on the home page, I am trying t ...

Customize chrome's default shortcuts with JavaScript

I'm working on an application that requires me to override some shortcut keys in the Chrome browser. While I'm able to create custom shortcuts to trigger alerts like in this Stackblitz example, I'm having trouble overriding a few default sho ...

Having trouble receiving time increments while utilizing the datetimepicker

I am using a datetime picker with jQuery and I would like to only select the time without the date. When I click on the input, I am only able to pick hours. How can I fix this? $(document).ready(function() { $.datetimepicker.setDateFormatter(&a ...

Using the ng-repeat directive in an angular-nvd3 tooltip

Looking to dynamically repeat values in the tooltip content of an nvd3 graph? Not sure how to achieve this using ng-repeat with JSON data? Seeking guidance on alternative methods? I can help! $scope.options = { chart: { type: ...

CSS fails to render properly on pages containing multiple query strings

An issue was initially reported by a customer using an IE browser (specific version unknown). I was able to reproduce the problem on my Samsung Galaxy 3 mobile's Chrome browser. The CSS is not being applied to the page when accessing this link with tw ...

Which event listener in the DOM API should I use to trigger an action when a form field is focused, whether through a mouse click or by tabbing?

My aim is to increase the size of form fields when the cursor focuses on them, either through a mouse click or by tabbing using the keyboard. By utilizing document.activeElement focus, I can identify when the user clicks inside a text input or selects an ...

Protractor's count() function fails to execute properly when called outside of a promise loop

var alerts = element.all(by.xpath("//div[@class='notification-content']")); alerts.count().then(function (val) { console.log(val); }); let compareValue = val; Is there a way to access the 'value' outside of the promise l ...

Issue with Material UI TextField and Redux Form integration

Having trouble with a textfield that I am trying to integrate with Redux Form. Here is how I have set it up: const renderTextField = props => ( <TextField {...props} /> ); Usage example: <Field id="searchCif" name="sear ...

When using the HTML5 input type time in Chrome and the value is set to 00:00:00, it may not be fully completed

After inputting the html code below <input id="time_in" type="time" step="1" name="duration"> and setting the value in the browser to "00:00:00", everything appears fine. However, upon inspecting the console or submitting the form, the value gets ...

Combining Laravel with React

Currently in the process of developing a substantial real estate listings platform with react and laravel. Can you suggest which approach would be better for this project and explain why? Option 1: Implement laravel react presets and store all react compo ...

Rails not receiving JSON data

I am attempting a straightforward ajax call in Rails 4, but encountering issues with retrieving the json response. Below is the script I'm working with: $(document).on "submit", "form[name=upvote-form]", -> form = $(this) $.post "/vote", $(th ...

What is the best way to split strings in an input field?

My task is to create a form with an input field and a dropdown list containing options for Checkbox and Radio. The user should enter text in the input field and select a type from the dropdown. For example: Input field: One, Two, Three Radio The expecte ...

Is there a method in ggplot2 geom_bar to subset two factors on the x-axis and group pairs within them?

In my dataset, I have recorded levels of glottals used in the speech of both children and their caregivers. The factors included are Speaker (a, amum, b, bmum...), Category (child, caregiver), and Pair (a and amum...). The plot I have generated illustrate ...

Streamline a javascript code with numerous elements

Seeking assistance in simplifying this code Currently, I find myself constantly updating this code each time a new entry is uploaded. I am looking for a solution where there is a single script that can identify the element IDs ("#rolly" or "#lagrimas") a ...

Matching with Regex beyond the limits

Trying to extract a body tag using regex and then replace it with an appended string. However, encountering an issue where the regex is selecting more content than intended. regex: /<body.*[^>]>/i test string: <bla bla ><body class=&apo ...

Issue with displaying images on Canvas when using Shiny's renderImage function

I am currently working on integrating Fabric.js into a Shiny app for interactive use. The goal is to have Shiny render an image, allow the user to modify it using Fabric, and then have Shiny read the modified image back for further processing on the server ...

Guide on Validating and Updating an embedded item within a mongoDB Collection Document

How do I go about updating the values of an embedded object within a mongoDB document? The values displayed for {{service.id}} and {{service.username}} in the table template are correct. However, I am unsure of the correct way to access them within the sa ...