How to expand tree view by default when page open in navision?

Question Status

Suggested Answer
ramesh reddy asked a question on 11 Apr 2018 12:21 PM

Hi All,

I have a page with show as tree property True. But when i run the page by default it was displayed in Collapse mode but i want to in expand.

i have done some R&D i found that below code 

IF (ISCLEAR(WshShell)) THEN BEGIN
CREATE(WshShell, FALSE, TRUE);
END;
WshShell.SendKeys('+{F10}E{ENTER}');
// menu key + E + Enter
CLEAR(WshShell);

But it is with the automation not working for my NAV 2013 R2. my page type is listpart. any other alternative way for the default expand in tree view.

Please let me know.

Thank You

--

Ramesh

Reply
Suggested Answer
RockWith NAV responded on 11 Apr 2018 1:12 PM

See this if you get some hint

rockwithnav.wordpress.com/.../update-flowfields-at-runtime-no-need-to-refresh

May be you SendKeys needs to be written twice.

Make sure you are writing at correct trigger.

Reply
ramesh reddy responded on 11 Apr 2018 1:17 PM

Hi,

Thanks for the reply. Please confirm me WshShell.SendKeys('+{F10}E{ENTER}'); this key is correct?

Thank You

Ramesh

--

Reply
Suggested Answer
ramesh reddy responded on 12 Apr 2018 12:00 PM

Hi,

I have a below page line like as sales subform.

And when page is loaded it need to be default expand how should i do. i found some sendkey code as below


IF (ISCLEAR(WshShell)) THEN BEGIN
CREATE(WshShell,FALSE,TRUE);
END;
WshShell.SendKeys('^+{Q}');
// menu key + E + Enter
CLEAR(WshShell);

manually Cntrl+Shift+Q is working for line hierarchy but when i written this code in OnOpenpage trigger not working.


IF "Is Parent" THEN
  WindowShell.Send('^+{Q}'); //^+{Q}

^+{Q} := Cntrl+Shift+Q (this is manually working)

And also above code is also not working in OnAftergetrecord trigger.

In which trigger i can place this code. even i have placed in Element name that is parent node onValidateTrigger but still not working. 

Please any one suggest me how to achieve. or any alternative way to achieve this situation.

Thank You

Ramesh

Reply
Suggested Answer
RockWith NAV responded on 12 Apr 2018 1:21 PM

It will obviously not work from OnOpen Trigger because its the Trigger of the main page not subform. You need to write on SubForm OnOpen  trigger and then it needs to be called from the main Page.

Reply
ramesh reddy responded on 12 Apr 2018 1:30 PM

Hi,

i have Written in Subform OnOpen trigger only, not on main page.

any other possibility for this?

Thank you

Ramesh

--

Reply
Suggested Answer
RockWith NAV responded on 12 Apr 2018 8:15 PM

See there's only two things that need to be taken care of.

1. SendKey should be correct if you are not passing it correct you wont get any Error but it will not work.

2. Trigger should be correct, OnOpen Trigger should work I believe, Possiblly you can try on some other triggers.

Make sure SendKey is correct, Check in some different short program, make confirm then go for triggers.

Reply
ramesh reddy responded on 12 Apr 2018 9:29 PM

Hi,

I have checked manually cntrl+shift+Q is worked for collage and expand.

I found keystrokes for cntrl as ^ ,shift +,{Q},

So totally my send key is '^+{Q}'.

Is above key I am passing is correct or do I need to change any thing.

Please suggest me.

Thanks you

Ramesh.

Reply
ramesh reddy responded on 16 Apr 2018 12:38 PM

Hi,

above send key was worked  on active application.

Name DataType Subtype Length

WindowShell DotNet System.Windows.Forms.SendKeys.'System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

WindowShell.Send('^+{Q}');

but i want to work this when loading a page. any one suggest the solution to resolve.

Thank you

Ramesh

--

Reply
Suggested Answer
Suresh Kulla responded on 16 Apr 2018 12:47 PM

Ramesh,

If you add an action on the page and add the above code is it working ?

Reply
ramesh reddy responded on 16 Apr 2018 12:53 PM

Hi Suresh,

presently i am handling through action only, but i want to expand all node by default when i run page. example 634 page need to expand all accounts.

can you suggest me, what should i do for that?

Thank you

Ramesh

--

Reply
Suggested Answer
Suresh Kulla responded on 16 Apr 2018 1:23 PM

Add the code on the OnAfterGetRecord but add a condition to execute it only on the last record. Get the COUNT in the open page and when it matches with the count execute your code.

Reply
Suggested Answer
Danil Batalov responded on 17 Apr 2018 3:13 AM

There is one way to open all tree nodes programmatically. 

For example (NAV 2015) in Page 634 you need make this changes:

1. Add global dot net variables (Must be RunOnClient=Yes)

CurrForm System.Windows.Forms.Form.'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
ContextMenuStrip System.Windows.Forms.ContextMenuStrip.'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
BusinessGrid Microsoft.Dynamics.Framework.UI.WinForms.Controls.BusinessGrid.'Microsoft.Dynamics.Framework.UI.WinForms.Controls, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
ArrayControls System.Array.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

(to add BusinessGrid copy Microsoft.Dynamics.Framework.UI.WinForms.Controls.dll to addins path, it is need only to add variable to page)

2. Add control (i name it PageReady) addin Microsoft.Dynamics.Nav.Client.PageReady;PublicKeyToken=31bf3856ad364e35 to page. It is need to get event when window form genereted.

3. In PageReady::AddInReady() write code like this

//Local Variables

FormID Code 40
RepeaterID Code 40
String DotNet System.String.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Application DotNet System.Windows.Forms.Application.'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
FormCollection DotNet System.Windows.Forms.FormCollection.'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

//Code

FormID := String.Format('{0:X8}',634); //634 is Page ID
RepeaterID := String.Format('{0:X4}',1); //1 is Repeater control ID

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);

ContextMenuStrip := BusinessGrid.DataGrid.Columns.Item(0).HeaderCell.ContextMenuStrip;
ContextMenuStrip.Items.Item(ContextMenuStrip.Items.IndexOfKey('{8173ED7E-096D-486f-AF68-873E8DE41170}')).PerformClick ;

Here is objects with some control feature :)

/cfs-file/__key/communityserver-discussions-components-files/34/P634_2D00_NAV2015.txt

/cfs-file/__key/communityserver-discussions-components-files/34/P634_2D00_NAV2017.txt

Reply
Suggested Answer
RockWith NAV responded on 11 Apr 2018 1:12 PM

See this if you get some hint

rockwithnav.wordpress.com/.../update-flowfields-at-runtime-no-need-to-refresh

May be you SendKeys needs to be written twice.

Make sure you are writing at correct trigger.

Reply
Suggested Answer
Suggested Answer
RockWith NAV responded on 12 Apr 2018 1:21 PM

It will obviously not work from OnOpen Trigger because its the Trigger of the main page not subform. You need to write on SubForm OnOpen  trigger and then it needs to be called from the main Page.

Reply
Suggested Answer
RockWith NAV responded on 12 Apr 2018 8:15 PM

See there's only two things that need to be taken care of.

1. SendKey should be correct if you are not passing it correct you wont get any Error but it will not work.

2. Trigger should be correct, OnOpen Trigger should work I believe, Possiblly you can try on some other triggers.

Make sure SendKey is correct, Check in some different short program, make confirm then go for triggers.

Reply
Suggested Answer
Suresh Kulla responded on 16 Apr 2018 12:47 PM

Ramesh,

If you add an action on the page and add the above code is it working ?

Reply
Suggested Answer
Suresh Kulla responded on 16 Apr 2018 1:23 PM

Add the code on the OnAfterGetRecord but add a condition to execute it only on the last record. Get the COUNT in the open page and when it matches with the count execute your code.

Reply
Suggested Answer
Danil Batalov responded on 17 Apr 2018 3:13 AM

There is one way to open all tree nodes programmatically. 

For example (NAV 2015) in Page 634 you need make this changes:

1. Add global dot net variables (Must be RunOnClient=Yes)

CurrForm System.Windows.Forms.Form.'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
ContextMenuStrip System.Windows.Forms.ContextMenuStrip.'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
BusinessGrid Microsoft.Dynamics.Framework.UI.WinForms.Controls.BusinessGrid.'Microsoft.Dynamics.Framework.UI.WinForms.Controls, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
ArrayControls System.Array.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

(to add BusinessGrid copy Microsoft.Dynamics.Framework.UI.WinForms.Controls.dll to addins path, it is need only to add variable to page)

2. Add control (i name it PageReady) addin Microsoft.Dynamics.Nav.Client.PageReady;PublicKeyToken=31bf3856ad364e35 to page. It is need to get event when window form genereted.

3. In PageReady::AddInReady() write code like this

//Local Variables

FormID Code 40
RepeaterID Code 40
String DotNet System.String.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Application DotNet System.Windows.Forms.Application.'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
FormCollection DotNet System.Windows.Forms.FormCollection.'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

//Code

FormID := String.Format('{0:X8}',634); //634 is Page ID
RepeaterID := String.Format('{0:X4}',1); //1 is Repeater control ID

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);

ContextMenuStrip := BusinessGrid.DataGrid.Columns.Item(0).HeaderCell.ContextMenuStrip;
ContextMenuStrip.Items.Item(ContextMenuStrip.Items.IndexOfKey('{8173ED7E-096D-486f-AF68-873E8DE41170}')).PerformClick ;

Here is objects with some control feature :)

/cfs-file/__key/communityserver-discussions-components-files/34/P634_2D00_NAV2015.txt

/cfs-file/__key/communityserver-discussions-components-files/34/P634_2D00_NAV2017.txt

Reply