Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem to create a modal form - SOLVED
#1
Dear all,
I tries to add a modal form to my intraweb app and I don't understand what is my mistake.
The structure of my app is :
- a home page to display my records
- a card template to design my records. Each card has a button to call the modal I need
- optional, an additionnal form to manage the modal. I would like to use an external form to avoid having an instance of the modal in each card I have to create.

For my modal, I tried to use a region inside my card or the optionnal additionnal modal form, and in each case the modal is created but it's empty.
[Image: empty_modal_za86nw.png]

I tried to set the ContentElement programmatically or using the Object Inspector, same result.
In the Object Inspector, I can select a component from my external form.
[Image: content_modal_ylnq58.png]
But I can use the same syntax when I want to assigned it at runtime, I have to create an object first. Is it the correct way to do that ?

This is the expected result :
[Image: expected_modal_ptgijh.png]

I attached a test case, hope somebody can have a look on it and help me to understand how i have to design this.

Regards,
Stéphane


Attached Files
.zip   modal.zip (Size: 29.29 KB / Downloads: 16)
Reply
#2
Hi Stéphane,

I'll run your test case and get back to you on this ASAP
Reply
#3
Thank you
Reply
#4
I checked your project and IW doesn't currently support that type of construction. The Object inspector shows all containers as possible candidates to be linked as a ContentElement, but at runtime the region parented to another form can't be used in a different form host. If you create the TIWFormModal at runtime (as shows the code in your test case that has been commented out) it will become the active form and you won't be seeing the old form on the browser anymore.

You can make it work correctly if you make it a frame instead of an IWform. In that case you must create the IWFrame at runtime and set the content element to the IWRegion on the frame
Reply
#5
Thank you for your advice, works fine with a frame AND after I include the region used for the modal to my HTML template.
Reply
#6
Great, thanks for the feedback
Reply
#7
Dear all,
Back again after few week without working on my project cause I have another problem with my modal.
Thanks to Alexandre, the render of the modal is what I want, but it doesn't work as expected and I don't understand why.

My testcase modal contains an IWEdit with data type stDate, an IWButton and an IWLabel.
On AsyncClick on the button, the selected date must be displayed in the label.
But when I test my modal, on click, the IWEdit text is always empty, so my label (or my variable in my real project) is empty.
I putted a breakpoint in my event, it's reached on click, but the IWEdit text is empty.
[Image: modal_eahoan.jpg]

For comparison, I created the same set of components (IWEdit, IWButton and IWLabel) on my home page, and in this case the IWEdit text is properly copied on click on the button.
[Image: home_q2yltx.jpg]

I don't understand the difference between the 2 cases and why my IWEdit is empty in my procedure even if I have a value selected in my modal.
I tried with a IWEdit with  data type stText, I have the same wrong result.

I already tried to use OnClick event instead of OnAsyncClick, but no chnage.
I also tried to encapsulate my 3 items in a form tag instead of a div and to assign manually the type submit to my button. In this case, when I select a date and press the button, the breakpoint is not reached and the modal is reset. At this moment, if I select another date and press the button again, the breakpoint is reached and the IWEdit text is available in my procedure. But not acceptable, I can't ask my user to do the job 2 times.

Hereby I join a new verson of my testcase, hope somebody can help me to understand what is the problem.
Many thanks for your help.


Attached Files
.zip   modal.zip (Size: 31.64 KB / Downloads: 4)
Reply
#8
Hi Stéphane,

I'll have a look and get back to you ASAP.

Cheers,
Reply
#9
Hi Stéphane,

This was a tough one.

There is a bug when there are multiple levels of frames like this. We have already fixed the bug so the fix will be available in the next release.

There is an easy workaround for you, while the fix is not available:

After creating the IWModalCard you can notify the owner form directly that there was a change (i.e. you have created a control youself), doing:

IWForm.RehashPending := True;

In your project you don't have direct access to the parent main form, however you can obtain it using the owner of the TIWFrameCard itself.

So it would be like:


Code:
uses
  uHome, IWForm;  // add IWForm here

procedure TIWFrameCard.IWButtonCardAsyncClick(Sender: TObject;
  EventParams: TStringList);
var
  oModal: TIWFrameModal;
begin
 
  with IWModalCard do
  begin
    Reset;
    //use region from uCard
    oModal := TIWFrameModal.Create(Self);
    oModal.Name := Owner.Name + '_FrameModal';
    oModal.Parent := IWRegionCardModal;
    oModal.IWLabelTitle.Caption := 'From button ' + (Sender As TIWButton).Tag.ToString;
    ContentElement := IWRegionCardModal;
    Autosize := True;
    HasHeader := False;
    HasFooter := False;
    CloseButtonVisible := False;
    Show;
  end;

  // Add this new code
  if (Self.Owner is TIWForm) then
    TIWForm(Self.Owner).RehashPending := True;
end;

Please have in mind that after the update this workaround is redundant and should be removed.

Cheers
Reply
#10
Hi Alexandre,
Thank you for your proposal, but the workaround doesn't work for me, I always need to select and validate my date 2 times, the first try doesn't run the event.
I tried with (Self.Owner is TIWForm) and (Self.Owner is TIWAppForm), but no change. The instruction RehashPending := True is reached in both case, so the problem doesn't come from the IF statement.

Do you have an estimated date of availability for the next release ? I can keep this point open for few weeks I think, I have a lot of other features to dev and test in my app, and i can use a form instead of a modal at the beginning, if no other solution.

Have a nice end of day and a nice week-end.
Stéphane
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)