How to Get a Cell Value in the Selection Event Handler

The 1C:Enterprise developers forum

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

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.

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

Joined:
Company:

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

 
#3
People who like this:0Yes/0No
Active user
Rating: 4
Joined: Sep 16, 2011
Company: Oksley Shipping

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.

 
#4
People who like this:0Yes/0No
Active user
Rating: 3
Joined: Sep 16, 2011
Company: individual

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", "")];

 
Subscribe
Users browsing this topic (guests: 6, registered: 0, hidden: 0)
Be the first to know tips & tricks 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.