Contacts

How to get a values \u200b\u200btable string. What methods exist and how to search simultaneously in several values

Search in 1c values \u200b\u200btable

What methods exist and how to search simultaneously in several values.

To search in the table of values \u200b\u200bthere are two special methods:

1. Find

TVGorizont \u003d reference books. Nomelaclature. Intepponation ("TV horizon");
Results \u003d Tznenenclature. Inite (TV, TV);
// Also we can specify in which speakers to search to speed up the search
Foundation \u003d Tznomenclature. Inite (TV, "Nomenclature");

This method returns the first found line with the desired value or undefined if it does not find. Therefore, it is convenient to use it to search for unique values, because Otherwise, you will have to delete it from the table when finding the following.

In order not to suffer, there is the following method that allows you to find an array of suitable lines:

2. Flight


Structuralboration. Hold ("Nomenclature", TVGorizont); // First, specify the column where to look for, and then what to look for.

This method always returns an array, but it can be empty if nothing is found. And this method also, as well as the previous returns the rows of the values \u200b\u200bof the values, and not the values \u200b\u200bthemselves in a separate array. Therefore, changing the values \u200b\u200bin the array row or in the previous method at the found line, you will change the value in the table of values \u200b\u200bprocessed.

The more good this method is that it can search at once in several columns of the values \u200b\u200btable at the same time:


Structures \u003d new structure;
Structuralboration. Hold ("Nomenclature", TVGorizont);
Structuralboat. Hold ("quantity", 10);
FoundationMassivests \u003d Tznenenclature. Entries (structures);

The only minus, as can be seen, can not be used other comparisons except "equal"

Probably not one object universal collections The values \u200b\u200bare not so popular with the 1C developers, which uses the values \u200b\u200btable (TK). Lists of values \u200b\u200bcannot be expanded by details, the tree of values \u200b\u200bis visually conveniently perceived, but the design of the program reading of its rows is difficult to implement.

And only the table of values:

  • Able to directly fill out tables of documents, reference books and treatments;
  • Is the result of the execution of the query;
  • Easy to read and clearly formed;
  • and many many others.

In this article we tried to give general view About such a complex and universal object as a table of values.

What is the values \u200b\u200btable

All novice developers clearly know that the table of the values \u200b\u200bare:

  1. Columns describing the structure of the table;
  2. Rows filling the table information.

However, we very often forget about one important property of the table - about its indexes, namely, the use of them allows to speed up the search process on the table repeatedly, the formation of selections in it and seriously improves the speed.

But first things first.

Figure 1 shows how the table of values, derived to print the simplest procedure, which shows their structure and filling.

As can be seen from the example, the columns at Table 5, not counting the line number in order.

In most cases, there is no need to specify the type of column data and its width, it is enough to determine the name of the column, but in some cases it is simply not to do without it (for example, when you unload the table to the DBF format file).

If in the future it is planned to use a value table as a data source for a query, the data type indication is necessary (Fig. 2).

Adding a row occurs by Add () method, with name assignment new String.

Table indices of values

The search on the table of values \u200b\u200bis carried out by two methods:

  • Find (Returns the first element found specific parametersotherwise the value is uncertain);
  • Farcasts (returns an array of a table string that satisfy certain conditions).

The search on the large tables strongly "hangs" the system and can be continued in time. It is in these cases that the indices should be used.

In the first case, the search occurs at one value and one column, it is necessary to transfer it to the indices (Fig. 3)

The indices passed through the comma indicate that the table can be selected by the Farcast method, into which a certain structure will be transmitted as a parameter.

In the case shown on the example, the second line indicates simultaneous search for lines containing specific value The nomenclature and its characteristics, and the third line it is indicated that the "Order for production" can be added to the search parameters.

When working with various objects of configuration metadata, as well as reports and processings, the situation often occurs when it is necessary to make some actions with their tabular parts. Work directly with form elements or table parts of documents is not always convenient.

Here the table of values \u200b\u200bcomes to the rescue. In TK, using the method table portions You can unload ():

  1. Fully repeat the structure of the document table, while maintaining the whole possible information;
  2. Determine only those columns and lines that are necessary for further work, and withdraw them.

The reverse action (filling table part) occurs by the method to upload (), the only parameter of which is the name of the displayed table.

It should be noted that the matching of the columns of the tabular part and TK occurs by names.

Completely copy one TK to another, and also determine which rows and columns will be transferred by the method to copy ().

Fig.4

At the same time, the columns of the table will be saved, and the information and rows from the duplicate will be deleted.

Table of values \u200b\u200band request

As mentioned above, unloading the result of the execution of the request occurs in the TK, but quite often the developers have a question: and as a query to process the table of values, is it possible, and what code helps to do this.

Query technology in 1C does not imply the use of TK as data sources, but this limitation can be easily bypass using. The code in Fig. 5 shows how it is done.

Fig.5

Replacing "*" to the name of the columns (string of the TZ.

Error when executing a query (Fig. 5) "The type cannot be processed in the query," says that the developer forgot to perform part of the code 2 and did not type columns.

Table of values \u200b\u200band cycles

When crossbow rows of the table of values \u200b\u200bby the method containing the counter (Fig. 6), it is important to remember that the initial value of the row index is 0, and the end value of the iterator should be 1 less than the number of rows in the table. Otherwise, there is a 100% chance of an error "The index value goes beyond the boundaries of the range"

Fig.6.

In general, the brute force of the TK rows is better to carry out through the design "for every ... from", by defining the name of the iterator.

Greetings all readers Infostart'a. This article will be devoted to the issue of creating an arbitrary table of values \u200b\u200bon the form of a managed application software.

Features of the task.

Everyone who programmed in the usual appendix often faced the task of obtaining an arbitrary table of values \u200b\u200bon the form. Under an arbitrary table of values \u200b\u200bis understood as the table, the number and type of columns of which is not known. That is, the columns can be 3, and maybe 6, or maybe 8. In the usual application, everything is simple: it was possible to place the "table apposition" element on the formation form, and then transfer the value table to the values \u200b\u200bto this item to this item. Then a simple team:

Elementforms. Ticketpassed. Calcons ();

receive finished table Values \u200b\u200bon the form. It would seem that it could be easier.

It was all in the usual application. In the managed application everything has changed. So simply an arbitrary table not to create. Now you need to either rigidly parametrate the table of values \u200b\u200bon the form, or create it programmatically (describe, well, in this, in fact, the essence of the authorized application itself). This we will try to do: software create an arbitrary table of values \u200b\u200bon managed form.

The solution of the problem.

The first thing we have to do is determine how the table appears on the form. The main thing is that no element of the form in the processing is not necessary. We will create it programmatically, like the entire table. That is, the table will be described, and to create at the time of opening the form or using the button - this is how it is necessary.

Creating a table on the form occurs through the description of the table of values \u200b\u200bas requisition:
Massiferboabor \u003d new array; Massifable customer. Addly (type ("table apposition")); DescriptionCarebar \u003d New descriptions (massifacivity); Massives \u003d New array; Massives. Addly (new requisite ("tablescript", descriptions, "", "TZN")); Now we have to create a software table of values \u200b\u200bthat contain data. If the value table is obtained from the request, then everything is less than the order. If the table is created manually, the value of the speakers that will contain numbers or dates can be created through the "Description". The bottom line is that the columns in the table of values \u200b\u200bmust have some kind of type. If, for example, it is assumed that the user will fill in the data in these columns interactively, then you cannot add the values \u200b\u200bof the values \u200b\u200bcolumn simply with the name, it should be type. Keep in mind - this is very important because We will give these types to the table on the form.
Create a table that contains several columns:
KD \u003d new qualificatory dates (particles. Veria); Massigs \u003d new array; Arms. Addly (type ("date")); Lookup graphics \u003d New descriptions (arms, CD); TK \u003d new tables;
TK.Colonki. Addly ("C", descriptions.
TK.Colonks. Addly ("to", descriptions.
TK.Colonki. Addly ("FULL NAME");
TK. Solonks. Addly ("Note"); // FULL NOTE - Rows Next, we will fill our software table TK with the necessary data. We obtain the TK table that contains the necessary values \u200b\u200band is ready for transmission to the created props of form. For each column of TK. Column cycle

Massiverevizites. Addly (new requisite (column. I mean, column. Type, "Taxcripts"));
EndCycle;
Changerevizes (massivevizites);
TablePoles Captivity \u003d Elements. Addly ("TZN", type ("tableform"));
TablePoles Capture. Powded \u003d "Taxcripts";
TablePoleSeboat. Example \u003d Displayed. Opportisses;

Here is such a simple combination and our table is ready.

For each column of TK. Column cycle

NewElent \u003d Elements. Addly (column. I mean, type ("Foreform"), TablePoles);
New element. Vid \u003d Vidpolar Form. Power;
New element. Powdly \u003d "Taxcripts." + Column.
New element.shirina \u003d 10;
EndCycle;

Conditional design, if we need we also write manually, command menu - manually. Table handlers are also written with hands. For example, to add an event handler "Selection" event:

TablePoles Capture. Setting ("Choice", "Tznvybor");

To process this event, a separate procedure is prescribed in the form of the procedure:

& Svalette
Procedure TZNVSB (TK, selected, field, standardworking)
// Processor Commands End Controlments

Please note that the table handlers are triggered on the client and therefore must have a compiler pointer command

& Svalette

Well, and the last thing I wanted to add that after all these actions, we definitely do not forget to transfer the finished table into the requisition of the form:

Recentlyrerevisitforms (TK, "Taxcripts");

Here is what we have as a result:


But the processing of the Event "Choice":



Afterword.

I hope the article will assist those programmers 1C, which begin to create tables on the form of the programmatic method.

You can download the processing that software creates a value table and displays a managed form with comments that will help you create your own tables.

In order to take into account money and goods, various tables use widely in business. Almost every document is a table.

The table lists the goods to shipment from the warehouse. In another table - obligations to pay for these goods.

Therefore, 1C prominent occupies work with tables.

Tables in 1C are also called "tabular parts". They have reference books, documents and others.

The request as a result of its execution returns a table, access to which it is possible to get in two different ways.

The first is faster - sampling, obtaining rows from it only in order. The second is unloading the result of the query in the values \u200b\u200btable and further arbitrary access to it.

// Option 1 - Sequential access to the results of the query

// Receive Table
Sampling \u003d query. Fill (). Select ();
// in order we go around all the rows of the query result
While sample. Next () cycle
Report (sample. Name);
EndCycle;

// Option 2 - unloading in the table of values
Request \u003d new query ("Select the name from the Directory. Namenclature");
// Receive Table
Table \u003d query. Fill (). Unload ().
// then we can also get around all the lines
For each row from the table cycle
Report (string. Name);
EndCycle;
// or arbitrarily access to lines
Line \u003d Table. Init ("shovel", "name");

An important feature is in the table that is obtained from the query result, all columns will be strictly typed. This means that by requesting the name field from the directory Nomenclature, you will receive a column of a string type with a permissible length of no more than N characters.

Table on the shape (thick client)

The user works with a table when it is placed on the form.

The basic principles of working with forms, we discussed in the lesson in the lesson in

So, place a table on the form. To do this, you can drag the table from the control panel. Similarly, you can select the form / insert control in the menu.

Data can be stored in the configuration - then you need to select an existing (previously added) table part of the configuration object whose shape you edit.

Press the "..." button in the data property. In order to see a list of tabular parts, you need to reveal the branch object.

When choosing a tabular part 1C itself adds columns at the table on the form. Rows entered by the user in such a table will be saved automatically along with the reference / document.

In the same property, you can enter an arbitrary name and select the type of table.

This means that an arbitrary table of values \u200b\u200bis selected. It will not add automatically columns, it will not be automatically saved, but it is possible to do with it anything.

By right-clicking on the table you can add a column. In the column properties, you can specify its name (for referring to 1C code), the column header on the form, the connection with the details of the tabular part (last - if not an arbitrary table, and the table part is selected).

In the properties of the table on form, you can specify whether to add / delete lines to the user. A more advanced form - a tick only. These properties are convenient to use to organize tables intended to display information, but not editing.

To manage the table, you need to display the command panel. Select the menu item Form / Insert control / command panel.

In the command panel properties, select a tick autofill that the buttons on the panel appear automatically.

Table on the shape (thin / managed client)

On managed form, the specified actions look a little differently. If you need to place on the shape of the tabular part - open the branch of the object and drag one of the table parts left. And all!

If you need to place the table of values, add a new form props and in its properties. Specify the type - the table of values.

To add speakers, use the menu on the right mouse button on this details of the form, the option add a propumes column.

After that, also drag the table left.

In order for the table to appear command panel, in the table properties, select the values \u200b\u200bin the Use section - the command panel position.

Disload Table in Excel

Any table 1C, located on the form, can be printed or unloaded into Excel.

To do this, right-click on the table and select Display List.

In the controlled (fine) client similar actions You can perform using the All Actions / List menu item.



Did you like the article? Share it