Filling the ValueTree as a form attribute from the query

The 1C:Enterprise developers forum

#1
People who like this:0Yes/0No
Active user
Rating: 6
Joined: Sep 16, 2011
Company:

How to work with the ValueTree? I have created the GoodsByWarehouses ValueTree on the Form, columns are the GoodsItem – the reference to Goods catalog and the Warehouse – the reference to Warehouses catalog, and the Quantity of Number type.
Here is my query:

Code
"SELECT
|   InventoryBalance.GoodsItem,
|   InventoryBalance.Warehouse AS Warehouse,
|   SUM(InventoryBalance.QuantityBalance) AS Quantity
|FROM
|   AccumulationRegister.Inventory.Balance AS InventoryBalance
|
|GROUP BY
|   InventoryBalance.GoodsItem,
|   InventoryBalance.Warehouse
|TOTALS BY
|   Warehouse";

Now I want to fill the form attribute with nodes by Warehouse.
But I can't figure out how to create nodes. Do I have to create a new ValueTree, fill it and convert to the FormData?
Code
Result = Query.Execute();

SelectionWarehouse = Result.Choose(QueryResultIteration.ByGroupsWithHierarchy);

While SelectionWarehouse.Next() Do
    TreeData = GoodsByWarehouses.GetItems();
EndDo;

 
#2
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

Use the following:

Code
// Getting the ValueTree from the query
TreeFromQuery = Query.Execute().Unload(QueryResultIteration.ByGroups);
// Placing the ValueTree on the form
ValueToFormAttribute(TreeFromQuery, "GoodsByWarehouses");

Or see the Syntax Assistant for: FormDataTree and FormDataTreeItem. The GetItems() method returns the collection of items of 1 level down. For the root it will be the top level items collection. After that you can work with that collection, add and/or delete items.

 
Subscribe
Be the first to know tips & trick on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.