Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Enterprise – Business applications platform > How to Get a Cell Value in the Selection Event Handler

Forum

Search UsersRules
How to Get a Cell Value in the Selection Event Handler
#1
Active user
Points:: 0
Joined:: Sep 16, 2011

I feel that it could be done very simple, but can’t get it for 2 hours already :)

There is a ValueTable placed on the form. ReadOnly mode.
Setting the Selection event handler, which occurs on double click or Enter.

Procedure PlanSelection(Item, SelectedRow, Field, StandardProcessing)

So, how to get the cell which had been double clicked from this handler?
The closest thing is Items.Plan.CurrentData.

But it is the whole row, while I need to know which column in this row it was. I believe, that it should be done through Field attribute, but can’t get how to.

Please don’t suggest to attach an event to each column due to the table is generated automatically. And I’ve already ordered a book about the interface.

Profile
#2
Guest
Points::
Joined::

You don’t need to attach the handler to each cell, there is a CurrentItem property, it is what you need.

Profile
#3
Active user
Points:: 0
Joined:: Sep 16, 2011

Sorry, I don’t understand. And I’m asking on how to get the value from the object of FormField type. The CurrentItem is of FormField type which I have in the event parameters already.

Profile
#4
Active user
Points:: 32
Joined:: Sep 16, 2011

You can get the value fr om the current dat a:

CellValue = Items.Plan.CurrentData[PathToCellData];

Where PathToCellData is a string with the path to the data of the edited item. The form field has DataPath property. Unfortunately it is not accessible at client even for reading, so there are two ways to solve the problem:

1. Call the server function in the Selection event handler wh ere the name of the edited field should be passed (the field itself could not be passed).

PathToCellData = PlanSelectionAtServer(Field.Name);

Getting the path to data at server and returning it to the client:

&AtServer
Function PlanSelectionAtServer(FieldName)
ContainerPath = "Object.Plan.";
// or ContainerPath = "Plan." if it is the form field rather than the object field
Return(StrReplace(Items[FieldName].DataPath, ContainerPath, ""));
EndFunction

2. It’s not a very nice to call server all the time, so you can agree with yourself to use naming rules which will allow you to find the DataPath from the field name, for example in the following way:

CellValue = Items.Plan.CurrentData[StrReplace(Field.Name, "Plan", "")];

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.