Integrated Application Platform › Forums › General › ExpandControl Refresh
- This topic has 14 replies, 2 voices, and was last updated 10 years, 2 months ago by
amckinlay.
-
AuthorPosts
-
June 22, 2013 at 7:32 pm #761
ajith
ParticipantHello,
I tried to use Expand Control to show the information from master table while entering records in the details table. The master table is StkMain and the details StEnTrade. The idea was when one sets a value in a particular field of StEnTrade, different rules will provide the values to the fields inside the Expand Control. The values from the most essential fields would be shown on the summary at top even when the Expand is collapsed. This should be sufficient most of the times, but the entire fields from the header table are available in case some one wants.
The problems:
1) The summary shown when the expand is collapsed is not refreshing as and when the value of the fields inside it change (in response to the change in selection made). The summary reflects the change if the expand is opened and then collapsed, but not automatically.
2)When an Expand is opened, a scroll appears, but it does not disappear when the Expand is collapsed.Similarly, if the Expand expands to such a size that it cannot be accommodated in the current window size, a Scroll does appear, but of only such “play” as to show the expanded expand, but not the controls outside the expand. All this is happening inside an Access and Expand & other controls are inside a Vert.
3)I did not understand the difference between NeedSummary method and MakeSummary method, though UserManual says “When the ExpandControl is closed it Send’s NeedSummary which can be used at the controller to provide a “Summary” of the data just hidden. If the controller does not respond to NeedSummary the control can have a MakeSummary method.
Abbreviated code for the StockMainShow Control which uses the Expand is as below:
PassthruController
{
Name: "StockMain"
New( title = '')
{
super(.layout( "Stock Main" ));
}
layout(title)
{
return Object('Expand' title
#(Vert (Horz (Skip 32) (showstockname) ......
}
MakeSummary()
{
return Join(' ', .showstockname.Get() ........)
}
The abbreviated code for the Access where it is used is
Controller
{
Controls:
(Access
'StkEnTrades'
(Center
(Horz
(Vert
(StockMainShow)
(sT_TradeNum) (Skip) (sT_Ticker)....
}
Rule_showstockname is based on the value of sT_Ticker.
What should I do to make my control derived from Expand to auto refresh each time the value of the control it holds changes?
Thanks in advance,
ajithJune 25, 2013 at 10:45 am #1002ajith
ParticipantHello,
Missed this?
ajithJune 25, 2013 at 2:01 pm #1003amckinlay
KeymasterSorry Ajith. I saw it but I need to do some research. I will try to get to it today.
June 25, 2013 at 4:49 pm #1004amckinlay
KeymasterExpandControl adds an observer to the parent RecordControl (supplied by AccessControl in this example). This should handle updating. You could put a Print in ExpandControl set_summary to see if it is getting called.
NeedSummary is a method you put on the Controller that contains the ExpandControl. MakeSummary is a method you put on the control within the ExpandControl. You can use whichever is more convenient. I am not sure how your example can work – it should be defining NeedSummary since it is on the Controller.
We mostly use ExpandControl as part of AccordionControl. I checked a few places and the scroll bars seem to work correctly. However, they were all inside TabsControl so that may be the difference. ExpandControl does .Window.Refresh() when it expands or contracts which should handle this.
June 26, 2013 at 4:41 pm #1005ajith
ParticipantHello Andrew,
Thanks for the reply. However, I will need more help.I am not sure how your example can work – it should be defining NeedSummary since it is on the Controller.
Sorry for the mistake. I am using NeedSummary though I posted code from an earlier version that was not working.
You could put a Print in ExpandControl set_summary to see if it is getting called.
I added Print(summary) before the .summary.Set(summary) statement in the set_summary method of Expand Control. This initially prints the string with just the space when the Access is run , followed by another string I kept inside the NeedSummary method. When I key in a value to the field in the Access based on which the values contained in the Expand changes, nothing is printed. Without changing the values, if I expand the Expand manually, no values are printed. When I close the Expand after this, it prints the values as expected and the same is then shown on the top. What would be the next step?
ExpandControl does .Window.Refresh() when it expands or contracts which should handle this.
Again, I am sorry. This issue is there only when I Center the Vert :
(Access
'StkExTrades'
(Center
(Horz
(Vert
(StockMainShow) ......June 26, 2013 at 5:01 pm #1006amckinlay
KeymasterIt sounds like the fields you are basing your summary on are not causing the Access’s RecordControl to notify it’s observers.
There must be a problem with Center and scrolling / sizing. We don’t center everything so this hasn’t been a problem for us. You could try using (Horz Fill … FIll) instead of Center (although that is basically what Center does so it may not help)
June 26, 2013 at 5:15 pm #1007ajith
ParticipantHello,
Thanks for the reply!The code for is Field_sT_ExitTicker. This is the field in the Access based on whose value I want the fields inside the Expand to change
Field_string
{
Prompt: "Ticker"
Control: (Key '((StkEnTrades project sT_Ticker) rename sT_Ticker to ticker) join StkMain' 'ticker' mandatory:true width: 12.8 fillin: (sT_StockName) from: (stockname) )
}One of the fields inside the Expand whose value is calcualted based on the value of Field_sT_ExitTicker is calculated using the Rule_sT_EnTradeNum
function()
{
rec = false
try rec = QueryFirst(("StkEnTrades where ( sT_Ticker = " $ Display(.sT_ExitTicker) $ " and sT_Type = " $ Display(.sT_Type) $ " ) sort sT_EntryDate"))
if Record?(rec)
return rec.sT_TradeNum
else
return false
}Is the reason for the field not notifying the Access’s Record Control any error in my code? Could the reason be just that it is a calculated field?
Thanks in advance,
ajithJune 26, 2013 at 5:27 pm #1008ajith
ParticipantHello,
Using (Horz Fill …..Fill) did solve the issue with the scroll being inadequate.Thanks,
ajithJune 26, 2013 at 8:49 pm #1009amckinlay
KeymasterIf you can attach or email me a complete functional example that is as small as possible I’ll take a look at it. Otherwise it is hard for me to know exactly what is happening.
June 27, 2013 at 9:17 am #1010ajith
ParticipantHello Andrew,
Thanks for the help in advance.
I am attaching debuglib with just TradeExitControl and the defenitions it is dependant on. You will have to run Ensure_StkExTrades to create the table. The master table for the table created by Ensure_StkExTrades ( StkExTrades) is StkEnTrades. I am attaching a copy of StkEnTrades with just one record.
Hope this wont eat up much of your time,
ajithJune 27, 2013 at 5:49 pm #1011amckinlay
KeymasterThe problem is that ExpandControl had:
.rc.AddSetObserver(.set_summary)
This will only call the observer when a new record is set i.e. when you go to a new record in the Access
If you change it to:
{
.rc.AddObserver(.set_summary)
.rc.AddSetObserver(.set_summary)
}Then it will be called whenever a field changes, which is what you are looking for.
June 28, 2013 at 9:32 am #1012ajith
ParticipantHello,
Adding the code to the Startup method, tthe issue is solved. Thanks.Can you explain what is happening when the code is executed?
if 0 isnt .rc = .Send('GetRecordControl')
{
.rc.AddObserver(.set_summary)
.rc.AddSetObserver(.set_summary)
}What I understand is that rc is assigned the value given by Send method defined in a parent (Control) of ExpandController. The argument given to Send method is ‘GetRecordControl’. What does Send method return? I am unable to Inspect rc -it is giving an error. What are the valid arguments that can be supplied to Send? What happens when AddObserver and AddSetObserver methods of rc are called withset_summary?
Thanks again,
ajithJune 28, 2013 at 2:46 pm #1013amckinlay
Keymaster.Send “sends” a message to parent Controller’s. (Only a Controller can respond to Send.)
You are probably more used to receiving these messages. For example, when you define an On_… method to respond to a button. The button is doing .Send(“On_…”)
If a parent Controller has a method with the same name as the first argument to Send (in this case “GetRecordControl”) then that method will be called with the remaining arguments to the Send (in this case there are no additional arguments).
If no method is found, then .Send returns 0.
In this case, the parent Controller with a GetRecordControl method is the RecordControl. It responds by returning itself.
Once we have the parent RecordControl, then we add “observers” to it. The method passed to AddSetObserver will be called by RecordControl whenever its Set method is called. The method passed to AddObserver will be added as an observer to the Record managed by the RecordControl. Record observers are called whenever a field is changed in the record.
I’m not sure why you can’t inspect rc, maybe because it has recursive self references.
Does that help?
June 29, 2013 at 5:39 pm #1014ajith
ParticipantHello Andrew,
Thanks a lot! It does help me to understand the basics. I need one clarification –.Send “sends” a message to parent Controller’s. (Only a Controller can respond to Send.)
You are probably more used to receiving these messages. For example, when you define an On_… method to respond to a button. The button is doing .Send(“On_…”)
When you say parent, you do not mean the parent from which the Controller inherits, do you? What I understood was that by parent you mean the Controller in which the particular controller is contained. In my case, StockEntryTradeShowControl inherits from PassthruController. However, when StockEntryTradeShowControl is used, it is used inside
Controller
{
Controls:
(Access
'StkExTrades'
(Vert
(StockEntryTradeShow) ......So StockEntryTradeShowControl is actually code written in StockEntryTradeShowControl + those methods in PassthroughController and its parent of inheritance which are not overridden in StockEntryTradeShowControl and by its parent you mean Vert and Access, in this particular example. Did I get it right?
Thanks again,
ajithJune 29, 2013 at 6:19 pm #1015amckinlay
KeymasterYes, by “parent” I mean the control that contains this one (not inheritance).
-
AuthorPosts
- You must be logged in to reply to this topic.