Cloud Computing Insider Awards 2022: Vote for ONLYOFFICE
Vote for ONLYOFFICE

How does the callback of the callcommand method transfer values

We can use Asc.scope object, passing parameters to the callcommand method
So what should I do if I want to get the value in callcommand from the callback of callcommand

window.Asc.plugin.callCommand(function () {
                var oWorksheet = Api.GetActiveSheet();
                var ActiveCell = oWorksheet.ActiveCell;
                var text = ActiveCell.GetComment();
                Asc.scope.text = text;
			}, false, false, function (a) {
				//How to get text
			});

Hello @shangshandalaohu
Could you please provide us with detailed scenario? What is your final goal? Please describe your usage scenario step-by-step.

Hello @Alexandre
First, I insert comments into the cell of the sheet through the following code

window.Asc.plugin.init = function() {
		var comment = document.getElementById("textareaIDComment");
		document.getElementById("buttonIDAddComment").onclick = function() {
			Asc.scope.textComment = comment.value; // export variable to plugin scope
			window.Asc.plugin.callCommand(function() {
				var oWorksheet = Api.GetActiveSheet();
				var ActiveCell = oWorksheet.ActiveCell;
				ActiveCell.AddComment(Asc.scope.textComment); // past comment in active cell
			}, true);
		};
	};

Then, I need to modify the comments of the cell through the plug-in. Step 1: select the cell. Step 2: click the plug-in I made to pop up the plug-in box. Step 3: get the comments according to the selected cell and add them to the plug-in control
Step 3 I don’t know how to operate at present

Step 3: get the comments according to the selected cell and add them to the plug-in control

Do I understand it right that you need to receive persisted comment from a cell to your plugin?

Just the opposite
I need to get the comments of the selected cells when the plugin is initialized

You can get comment from a cell like this:

this.callCommand(function () {
var oWorksheet = Api.GetActiveSheet();
var ActiveCell = oWorksheet.ActiveCell;
ActiveCell.GetComment();
}, true);

I know it can be obtained through the callcommand method, but after obtaining it, it cannot be passed to the control in the plugin. The plugin can be obtained through asc Scope passes parameters to callcommand, but callcommand cannot return values to the plugin

(function (window, undefined) {
    window.Asc.plugin.init = function (text) {
        window.Asc.plugin.callCommand(function () {
            var oWorksheet = Api.GetActiveSheet();
            var ActiveCell = oWorksheet.ActiveCell;
            var text = ActiveCell.GetComment();
            //document.getElementById("textComment") = text;
        });
    }

})(window, undefined);

For example, in this code, how can I assign a value to a control with ID textComment after I get comments

Thank you for description.
Unfortunately, we don’t have such methods at the moment. We added a suggestion to internal tracksystem (internal number - 58063). We have started working on it.

Sorry for inconvenience.