1c 8.3 cell properties parameters decoding
Question: Please advise how to do the following.
I have a query result displayed in a spreadsheet document, there is a decryption for the cell.
I want to double-click on a cell to run a procedure that, for example, launches a report on cell decryption.
Answer: Decryptions are standard and non-standard.
i) Standard:
can be used both directly in a spreadsheet document and in the SpreadsheetDocumentField object (that is, a spreadsheet document placed not in a separate window, but directly on the form).
For Decryption to work, 3 conditions must be met:
1) For the cell of the spreadsheet document from which we want to call the Decryption, the propertyDecryptionParameter must be set. For example, we want double-clicking on the cell with the name of the counterparty to open the form of the element of the Counterparty's reference book so that we can clarify some data that is not displayed in the report. Set the DecryptionParameter property to some value, for example, AccountDecryption.
2) In the process of outputting layout areas to the resulting spreadsheet document, it is MANDATORY to assign the value of the required type to the decryption parameter, for example:
Code 1C v 8.x TabDoc = New SpreadsheetDocument;
Selection = Directories.Contractors.Select();
// .................................................
Scope.Parameters.DecryptionAccountant = Selection.Reference;
TabDoc.Output(Region);
EndCycle;
3) There must be a ban on editing a cell with decryption, i.e. must be specified
TabDoc.ViewOnly = true;
otherwise, despite the promising appearance of the cursor, when hovering over a cell, you can click on it as much as you like, but nothing will happen.
II) Non-standard:
by double-clicking on a cell with a decryption, you can call your own procedure. To implement this, several conditions must be met:
1) The output of a spreadsheet document should be carried out in the SpreadsheetDocument Field object;
2) A value must be assigned to the cell property ParameterDecryption, for example, DecryptionAccount.
3) The decryption parameter Decryption of the Counterparty is assigned the List of Values filled with the necessary values during the formation of the spreadsheet document or, more often, the Structure. In particular, the name of the standard configuration report and the parameters to be set in the report form, such as date period, account number, etc., can be passed. And then this report is called as a procedure.
4) For the SpreadsheetDocument Field object, the ViewOnly property must be set to True.
5) The user procedure code is placed in the procedure
1C v 8.x Code
// the first line in it should be like this:
StandardProcessing = False;
I will give a small example that opens a subordinate directory for the "clicked" counterparty.
Code 1C v 8.x Procedure ButtonGeneratePress(Button)
Contractors = Directories.Contractors;
Selection = Counterparties.Select();
Tab = FormElements.SpreadsheetDocumentField1;
Layout = GetLayout("Layout");
While Selection.Next() Loop
If Selection.ThisGroup = False Then
Region = Layout.GetRegion("String");
Scope.Parameters.Account = Selection.Description;
.................................................................................................
StructDecryption = New Struct;
StructureDecoding.Insert("Account", Selection.Reference);
StructureDecryption.Insert(".......",.........);
.........................................................................
Scope.Parameters.DecryptionAccountant = StructureDecryption;
FormElements.SpreadsheetDocumentField1.Output(Area);
Otherwise
Proceed;
EndIf;
EndCycle;
FormElements.SpreadsheetDocumentField1.ViewOnly = True;
EndProcedure
procedure
StandardProcessing = False;
Contracts = Directories.Contracts.GetListForm();
Contracts.ParameterSelectionByOwner = Explanation.Contractor;
Contracts.Open();
EndProcedure
In this lesson, we will learn how to create tabular layouts in 1C, which can later be used for.
For example, how I generated layouts for .
I went to the processing form and went to the "Layouts" tab:
The spreadsheet editor opens:
In many ways, working in the editor is similar to working in Excel, but there are some peculiarities that I would like to dwell on.
What do I mean by region? These are several lines and several cells, in general, any part of a spreadsheet document that can be selected by us using the left mouse button.
Here is a selection of two lines:
And here is the selected area with 2 columns:
And now we will select the area at the intersection of the first two rows and the first two columns:
So. If we managed to select the area we need, then by right-clicking on it and selecting the "Properties" item, we can give it a name by which we will refer to it from our code, forming a printable:
This is the basic skill that we need to master in order to be able to make tabular layouts.
How to view already assigned names
And let's see what names are already assigned to the areas in the layout?
To do this, select from the configurator menu:
Here it is our newly assigned "Header" area:
And if now we select it in the dialog and press "Select", then the corresponding will be selected in the editor. cell area:
How to set the scope parameter
Often, when forming a printable area, it is required not only to remove the area from the layout. You also need to fill certain cells with certain parameters.
We set these parameters for the area and the given values automatically fall into the desired cells.
To do this, in the properties of the cell we need (where the parameter value will be displayed) ...
Specify the value "Parameter" in the "Filling" field, and in the "Parameter" field we write the name by which we will refer to this parameter from the code:
If you specify in the filling not "Parameter", but "Template", then it will be possible to indicate some text (template) in the cell itself using the parameter name in square brackets:
In this case, the parameter name (and its position in the template) is enclosed in square brackets.
How to set the decryption option?
The name of the decryption parameter is set in the same cell properties:
Later, from the code, we will assign this parameter (by the name "Nomenclature Decoding") the desired value (a reference to the item of the nomenclature).
And when the user double-clicks on this cell, the value assigned to the decryption parameter will open for him (in this case, the form of the nomenclature element will open).
Further parting words
We've covered the necessary basics. Now examine carefully.
Download this database. in it the processing "Processing for Tests".
Its layouts have tabular options. Explore them as thoroughly as possible, relying on the techniques that we discussed just above.