Hi,
I'll try to be clear on that one. I want to get the column ID i'm currently focusing. For example, in the screenshot :
1. The user type default values in Area 1 (Red)
2. He focuses the cell he wants the default values to be typed (Area 2 in blue + Area 5 in pink)
3. When he presses enter on the cell, the line is created in Area 3 (green) with the correct "Resource No." and "Date"
Problem is, if I just type the data manually, it'll work because in the code I passed 1, 2, 3 etc... depending on which "OnAfterValidate" it is. And i want to use the button marked as 4 ("Create Line") to automatically fill the value "10" (in area 1) into the cell i'm focusing.
Is there any way to achieve it ? The only thing to have is basically the currently focused column ID (from 1 to 12 in this example).
Thanks.
Answers
Hard task is to get BusinessGrid dot net variable for your page. I make it so:
1. Add to you page ControlAddin Microsoft.Dynamics.Nav.Client.PageReady
2. In trigger PageReady::AddInReady() write this code:
//PageID - number of your page, ControlID - number of repeater
//Global Variable
//FormCollection System.Windows.Forms.FormCollection.'System.Windows.Forms
//String System.String
//CurrForm System.Windows.Forms.Form
//ArrayControls System.Array
//BusinessGrid Microsoft.Dynamics.Framework.UI.WinForms.Controls.BusinessGrid
//Application System.Windows.Forms.Application
FormID := String.Format('{0:X8}',PageID);
RepeaterID := String.Format('{0:X4}',ControlID);
FormCollection := Application.OpenForms;
CurrForm := FormCollection.Item(FormCollection.Count-1);
RepeaterID := COPYSTR(CurrForm.Name,1,15) + RepeaterID + '-0008-' + COPYSTR(CurrForm.Name,26);
ArrayControls := CurrForm.Controls.Find(RepeaterID, TRUE);
IF ArrayControls.Length = 0 THEN EXIT;
BusinessGrid := ArrayControls.GetValue(0);
3. In you action button
MESSAGE('%1',BusinessGrid.DataGrid.CurrentCell.ColumnIndex);
It Is only column index in grid, get some method and properties to get additional info about column.
PS
It seems that this method not work when page opens in work area.
I only get this for "Microsoft.Dynamics.Framework"
In the "Server" Tab
First when I open the page :
Second, when I click the Action :
I think the error might wome from what you call "PageID" and "RepeaterID". Here's what i took :
Page ID :
And RepeaterID :
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
RepeaterID is ok but better make for example number = 1, it is not ok for big value (i do not know why )
And i forgot to say that dot net variables must be declared RunOnClient=Yes.
In dot net, variables transfers by reference, so your Currform variable it is single reference to page. And when variable cleared it is destroy own page.
Where do you find the dll:
Microsoft.Dynamics.Framework.UI.WinForms.Controls.BusinessGrid.DataGrid.CurrentCell.ColumnIndex
I only have these ?
Microsoft.Dynamics.Framework.UI.WinForms.Controls.dll
Do you make this in AL or C/AL
When I registrate the
Microsoft.Dynamics.Framework.UI.WinForms.Controls.BusinessGrid in my Variables I do not get any triggers in the page??
//String System.String
//ArrayControls System.Array
It is mostly working now - but I get this message - it seems like the pageReady code dont are executed - when should that be run?
clicking on action.
The code in the AddinReady trigger do not start. I add the add-in in the property of cell of matrix. Is that correct?
Can you help me?
Thanks
Edit:
Resolved adding new field without source so that the event is now triggered.