FoxInCloud
Problem loading a form
Gravatar is a globally recognized avatar based on your email address. Problem loading a form
  Michele
  All
  Dec 22, 2021 @ 08:53am

I have a form with a pageframe... In Page1 the user can enter some parameters and in page2 i make a query and i show the result.. In page2 i have some buttons to work on shown data... The problem i have is that when i enter the second page the first time i am not able to use the buttons i have and sometime data are not shown.... If i exit the form and open it again, i insert my parameters and when i go to page2 i can use all buttons and i can see selected records....

I have no error messages.... Some suggest on what to check ?

Thanks

Gravatar is a globally recognized avatar based on your email address. re: Problem loading a form
  FoxInCloud Support - Thierry N.
  Michele
  Dec 22, 2021 @ 01:05pm

Ciao Michele

We need code to help you

In which event do you update page 2? With what code?

Gravatar is a globally recognized avatar based on your email address. re: Problem loading a form
  Michele
  FoxInCloud Support - Thierry N.
  Dec 23, 2021 @ 01:13am

Here is all the code of the form In init() i fill the first grid...where with a button i can go to page2 running a query and filling the second grid

form.init()

Lparameters cUser
If Pcount() > 0
	DoDefault()
	With This	
		.User = cUser
		.RunQuery()
	EndWith
Endif

form.runquery()

This.Pagine.Page1.Grid1.RecordSource = ""

=Use("Rtt")
=Use("CliFor")
Select Rtt->Ido, Rtt->Mag, Rtt->Doc, Rtt->Dt1, Rtt->Dsd, Rtt->Com, Rtt->Ccf, Rtt->Dcf, Rtt->Mnt, Rtt->Mds, Nvl(CliFor->Ras1,Space(40)) As Mds_Ras1 ;
	From Rtt;
	Left Outer Join CliFor On CliFor->Code = Rtt->Mds;
	Where Empty(Rtt->Dor) And Rtt->Tdo = "MM" and Substr(Rtt->Doc,5,2) = "RA";
	Order By Rtt->Mag;
	Into Cursor tMov ReadWrite

Use In Rtt
Use In CliFor

Update tMov Set Mnt = Strtran(Mnt,Chr(13)+Chr(10),"<br>")
Go Top

With This.Pagine.Page1.Grid1
	.RecordSource = "tMov"
	.Column1.ControlSource = "Mag"
	.Column2.ControlSource = "Dt1"
	.Column3.ControlSource = "Dsd"
	.Column4.ControlSource = "Ido"
EndWith

If This.wBSlHTMLgen
	Local oGrid
	Local cScript
	oGrid = This.Pagine.Page1.Grid1
	oGrid.wcHTMLgen(@cScript)
	ThisForm.wcScriptJSadd([jQuery("#] + oGrid.wcIdBs + [").replaceWith(] + cLitteralJs(oGrid.wcHtml) + [);] + cScript)
Endif

page1.Grid1.wchtmlgen

LPARAMETERS toHTMLgen AS awHTMLgen OF awHTML.prg, tlInnerHTML && {en} doc in Parent Code {fr} doc dans le code parent

If Thisform.wBSlHTMLgen

	This.AddProperty("wcIdBs",This.wcID + "_bs")
	This.wcHTML  = [<div class="panel-group" id="] + This.wcIdBs + [" role="tablist" aria-multiselectable="true">]
	If Used("tMov")
		nRow = 0
		Go Top In tMov
		Do While !Eof("tMov")
			nRow = nRow + 1
			cRow = Padl(nRow,3,"0")

			TEXT to This.wcHTML textmerge additive noshow flags 1

				<div class="col-sm-12 panel panel-default">
					<div role="tab" id="<<Alltrim(tMov->Mag)>>">
		                <div class="col-sm-2 col-lm-2 col-lg-2 col-xl-2 btn-group btn-group-main-apps " data-row="<<tMov->Mag>>">
	                        <button class="btn btn-default btn-list-select" id="<<wcId(This.Column4._CommandButton1)>>">
	                        <span class="fa fa-check-circle fa-2x" aria-hidden="true"></span>
	                        </button>
						</div>
						<div class="lead col-sm-3 list-title"><<tMov->Mag>></div>
						<div class="lead col-sm-3 list-title"><<Dtoc(tMov->Dt1)>></div>							
						<div class="lead col-sm-4 list-title"><<Alltrim(tMov->Mds_Ras1)>></div>							
					</div>
					<div class="lead list-subtext"><<Alltrim(tMov->Mnt)>></div>							
				</div>

			EndText
			Skip In tMov
		EndDo
	Endif
	This.wcHTML = This.wcHTML  + [</div>]
Endif	

Local cScript

TEXT to cScript textmerge noshow flags 1
	jQuery("#<<This.wcIdBs>> button").click(function(event) {
		var rowId = jQuery(this).parent().data("row");
		jQuery.proxy(FoxInCloud.DOMEvent,FoxInCloud)(rowId,false,event);
		})
ENDTEXT

If Vartype(toHTMLgen) = "O" &&Intial HTML generation
	toHTMLgen.cScriptJsAdd(cScript)
Else
	toHTMLgen = cScript
EndIf


page1.grid1.Column4._CommandButton1.Click

Lparameters cMag

IF (Type('m.thisForm.wlHTMLgen') == 'L' AND m.thisForm.wlHTMLgen)  
	RETURN .T.
Endif
If VarType(cMag) = "C"
	ThisForm.runQueryMov(cMag)
EndIf

Return DoDefault()

form.runqueryMov()

Lparameters cMag

This.Pagine.Page2.Grid1.RecordSource = ""

=Use("Rmb")
=Use("Rtt")

Select Rmb->Iri, Rmb->Cod, Rmb->Des, Rmb->Con, Rmb->Ido, $0 as Qta, .f. As Sel ;
	From Rmb ;
	Left Outer Join Rtt On Rtt->Ido = Rmb->Ido;
	Where Rmb->Mag = m.cMag And (Rmb->Mpr != Rtt->Mpr Or Rmb->Mds != Rtt->Mds) ;
	Into Cursor Righe ReadWrite

Index On Iri Tag Iri Candidate

Use in Rmb
Use In Rtt

Go Top In Righe

This.Ido = Righe.Ido

With This.Pagine.Page2.Grid1
	.RecordSource = "Righe"
	.Column1.ControlSource = "Cod"
	.Column2.ControlSource = "Des"
	.Column3.ControlSource = "Qta"
	.Column4.ControlSource = "Sel"
EndWith

=Use("Rtt")
=Use("CliFor")

=Seek(Righe.Ido,"Rtt","Ido")
If !Empty(Rtt.Mds)
	=Seek(Rtt.Mds,"CliFor","Code")
	This.Pagine.Page2.Deposito.Value = Alltrim(CliFor.Ras1)
Else
	This.Pagine.Page2.Deposito.Value = "SEDE"
Endif

Use In Rtt
Use In CliFor

This.Pagine.ActivePage = 2

This.Pagine.Page2.Grid1.Refresh_()

page2.grid1.wchtmlgen()

LPARAMETERS toHTMLgen AS awHTMLgen OF awHTML.prg, tlInnerHTML && {en} doc in Parent Code {fr} doc dans le code parent

DoDefault(toHTMLgen)
If Thisform.wBSlHTMLgen
	This.AddProperty("wcIdBs", This.wcID + "_bs")
	This.wcHTML  = [<div class="panel-group" id="] + This.wcIdBs + [" role="tablist" aria-multiselectable="true"></div>]
	toHTMLgen.cScriptJSadd("FoxInCloud.inputAlwaysBlur=false;")
Endif	

page2.grid1.refresh_

lparameters void_parameter_reminder_implement_your_Refresh_code_in_this_method
if !(lProperty(this, 'wcIdBs') and ga_Type_IsChar(this.wcIdBs, .T.))
	return
endif

Local abSelect, abRecno, abPoint, abSep, cTxtID, cChkID, cHTML, cScript, nTabIndex

cHTML = ''
nTabIndex = 10
If Used("Righe")
	
	abRecno  = abRecno('Righe')
	abSelect = abSelect('Righe')
	abPoint = abSet('point', '')
	abSep = abSet('separator', '')
	cTxtID = wcID(this.columns(3).txt)
	cChkID = wcID(this.columns(4).chk)
	
	Do While !Eof("Righe")
		
		TEXT to cHTML textmerge additive noshow flags 3
			<div class="col-sm-12 panel panel-default" data-rowid="<<Righe->Iri>>">
				<div class="riga" role="tab">
					<div class="lead col-sm-3 list-title"><<allTrim(Righe->Cod)>></div>
					<div class="lead col-sm-4 list-title"><<allTrim(Righe->Des)>></div>							
					<div class="lead col-xs-2 col-sm-1 col-sm-1 list-title"><<Ltrim(Transform(Righe->Con,'@Z 999,999.99'))>></div>							
					<input type="number"   class="lead col-sm-2 list-title border <<m.cTxtID>>" value="<<Ltrim(Transform(Righe->Qta,'@Z 999,999.99'))>>" step="1.00" tabindex="<<m.nTabIndex>>">
					<input type="checkbox" class="lead col-sm-1 list-title <<m.cChkID>>"<<Iif(Righe->Sel, " checked", "")>> tabindex="<<m.nTabIndex+1>>">
				</div>
			</div>
		EndText
		nTabIndex = m.nTabIndex + 2

		Skip In Righe
	EndDo
	
	
	_cliptext=cHTML
Endif

TEXT to cScript textmerge noshow flags 3
	jQuery("#<<This.wcIdBs>>").html(<<cLitteralJS(m.cHTML)>>)
	var EventRequest = jQuery.proxy(FoxInCloud.EventRequest, FoxInCloud);
	jQuery("#<<This.wcIdBs>> div.panel").each(function(idx, elem){elem.addEventListener('click', function(event) {EventRequest(
			  "DOMEvent"
		  , event
		  , this
		  , jQuery(this).data("rowid")
		  , "<<this.wcID>>"
			)}, true);});

	var mousedown = false;
	jQuery("#<<This.wcIdBs>> .<<m.cTxtID>>")
		.mousedown(function(){
    	mousedown = true;
		})
		.focus(function(event) {var row = this.parentElement.parentElement; !mousedown && EventRequest(
			  "DOMEvent"
		  , 'click'
		  , row
		  , jQuery(row).data('rowid')
		  , "<<this.wcID>>"
			);
			mousedown=false;
			})
		.blur(function(event) {EventRequest(
			  "DOMEvent"
		  , event
		  , this
		  , jQuery(this).val()
		  , "<<m.cTxtID>>"
			);});
			
	jQuery("#<<This.wcIdBs>> .<<m.cChkID>>").click(function(event) {EventRequest(
			  "DOMEvent"
		  , event
		  , this
		  , undefined
		  , "<<m.cChkID>>"
			);});
			
ENDTEXT

thisForm.wcScriptJSadd(m.cScript)

Gravatar is a globally recognized avatar based on your email address. re: Problem loading a form
  FoxInCloud Support - Thierry N.
  Michele
  Dec 24, 2021 @ 03:14am

Ciao Michele

You should ALWAYS call .Refresh() instead of .Refresh_()

eg. This.Pagine.Page2.Grid1.Refresh() instead of This.Pagine.Page2.Grid1.Refresh_()

Please try this change beforehand.

Gravatar is a globally recognized avatar based on your email address. re: Problem loading a form
  Michele
  FoxInCloud Support - Thierry N.
  Dec 24, 2021 @ 06:18am

Changed Refresh_() with Refresh(), but nothing has changed

Gravatar is a globally recognized avatar based on your email address. re: Problem loading a form
  FoxInCloud Support - Thierry N.
  Michele
  Dec 26, 2021 @ 02:13am

On this line
Do While !Eof("Righe"),
are you sure of Bof("Righe")?

You should always use scan…endscan instead; much safer.

page2.grid1.refresh_
lparameters void_parameter_reminder_implement_your_Refresh_code_in_this_method

if !(lProperty(this, 'wcIdBs') and ga_Type_IsChar(this.wcIdBs, .T.))
	return
endif

Local abSelect, abRecno, abPoint, abSep, cTxtID, cChkID, cHTML, cScript, nTabIndex

cHTML = ''
nTabIndex = 10
If Used("Righe")
	
	abRecno  = abRecno('Righe')
	abSelect = abSelect('Righe')
	abPoint = abSet('point', '')
	abSep = abSet('separator', '')
	cTxtID = wcID(this.columns(3).txt)
	cChkID = wcID(this.columns(4).chk)
	
	Do While !Eof("Righe")
		

Gravatar is a globally recognized avatar based on your email address. re: Problem loading a form
  Michele
  FoxInCloud Support - Thierry N.
  Dec 26, 2021 @ 07:03am

Changed, but as expected, it doesn't solve the problem...

Gravatar is a globally recognized avatar based on your email address. re: Problem loading a form
  FoxInCloud Support - Thierry N.
  Michele
  Dec 27, 2021 @ 05:07am

I am not able to use the buttons I have and sometimes data are not shown

Which buttons? can't find them in code

Why do you use This.Pagine.Page2.Grid1.Refresh() and not This.Pagine.Page2.Refresh()? If buttons are on the page, they also need be refreshed.

Did you set a breakpoint in page2.grid1.refresh_ to see how it executes?

Also, like always, could you share a screenshot (or better a screencast) of your form showing the issue?

as expected

not appreciated… whenever you require help on code, telling what you've tried beforehand is welcome : http://catb.org/~esr/faqs/smart-questions.html#code

Gravatar is a globally recognized avatar based on your email address. re: Problem loading a form
  Michele
  FoxInCloud Support - Thierry N.
  Dec 27, 2021 @ 06:18am

Here is a video that shows the problem and how is the form...

Gravatar is a globally recognized avatar based on your email address. re: Problem loading a form
  FoxInCloud Support - Thierry N.
  Michele
  Dec 27, 2021 @ 07:10am

Thanks for the screencast!

Do you also intend to answer my questions?

Gravatar is a globally recognized avatar based on your email address. re: Problem loading a form
  Michele
  FoxInCloud Support - Thierry N.
  Dec 27, 2021 @ 07:23am

Which buttons? can't find them in code

Buttons are in the second page... The code is in the buttons

LPARAMETERS nButton, nShift, nXcoord, nYcoord

IF (Type('m.thisForm.wlHTMLgen') == 'L' AND m.thisForm.wlHTMLgen)
	RETURN .T.
ELSE  
Local cReport
cReport = GetStringFromIni(ThisForm.Name,"ReportMov","", wSetFile)
ThisForm.wForm("_form_movimenti_print","",ThisForm.User, ThisForm.Ido, .F., cReport)
ENDIF  

This is the print button code

Why do you use This.Pagine.Page2.Grid1.Refresh() and not This.Pagine.Page2.Refresh()? If buttons are on the page, they also need be refreshed.

Because i never used this and in other forms i have no problems. To be sure i tried yuour suggest without success. Nothing has changed.

Did you set a breakpoint in page2.grid1.refresh_ to see how it executes?

Tried but nothing seems to be particular. Still working on it....

Gravatar is a globally recognized avatar based on your email address. re: Problem loading a form
  FoxInCloud Support - Thierry N.
  Michele
  Dec 28, 2021 @ 02:48am

Here is a video that shows the problem and how is the form...

I can only see the page 2 buttons not responding, grid data looks OK
right?

If so,

Can you see in browser dev. tools what happens to the button?

To me, the buttons are .Enabled, just they don't have a .click handler attached.

Did you check for JavaScript errors when form displays?

Gravatar is a globally recognized avatar based on your email address. re: Problem loading a form
  Michele
  FoxInCloud Support - Thierry N.
  Dec 28, 2021 @ 03:02am

When the form is loaded and i am on the first page. I have this error

Gravatar is a globally recognized avatar based on your email address. re: Problem loading a form
  FoxInCloud Support - Thierry N.
  Michele
  Dec 28, 2021 @ 03:05am

Please click on the links to get to the offending instruction, and get at line and col of the corresponding script.

Gravatar is a globally recognized avatar based on your email address. re: Problem loading a form
  Michele
  FoxInCloud Support - Thierry N.
  Dec 28, 2021 @ 03:16am
 // ------------------------------------------------------------------------------
  DOMreadyUpdate: function (loIntuiCat, location, newWindow, locDelayS){ // Modifie les propiétés des objets de l'écran

    var success = true
    , script;

    // Si des scripts sont à exécuter AVANT les modifications du DOM
    script = this.oDOMEltChild(loIntuiCat, 'script');
    if (script && script.firstChild){
//    script = jQuery('<div/>').html(script.firstChild.nodeValue).text(); // https://stackoverflow.com/questions/1912501/unescape-html-entities-in-javascript
      script = script.firstChild.nodeValue;
      this.focusSet = this.focusSet || script.indexOf('.focus(') > -1;
      if (script) eval(script);
    }

    // Si le DOM est à modifier
    var loProps = this.oDOMEltChild(loIntuiCat, 'PCHTML'); // cf. awAJAX.XMLPropsAdd()
    if (loProps){
      success = this.PageUpdate(loProps);
      if (!success) this.Error(this.langFR
        ? "Échec de la mise à jour de la page"
        : "Page update failed"
        );
    }
    if (success){
        
      // Si des scripts sont à exécuter APRÈS les modifications du DOM
      script = this.oDOMEltChild(loIntuiCat, 'script_');
      if (script && script.firstChild){
//      script = jQuery('<div/>').html(script.firstChild.nodeValue).text(); // https://stackoverflow.com/questions/1912501/unescape-html-entities-in-javascript
        script = script.firstChild.nodeValue;
        this.focusSet = this.focusSet || script.indexOf('.focus(') > -1;
        if (script) eval(script);
      }

      this.BSgroupBtnBorderFix(); /* 2020-05-14 thn -- {FiC V 2.31.0-beta.2} {en} added */

      // Si redirection, exécuter
      if (location) {
        location = location.firstChild ? location.firstChild.nodeValue : '';
        var locationChange = jQuery.proxy(function(){
          var $body = jQuery(document.body);
          location
            && this.requestFormOpacity > 0
            && this.requestFormOpacity < 1
            && $body.css('opacity', this.requestFormOpacity * .9)
            && window.setTimeout(function(){$body.css('opacity', 1);}, 1000)
            ;
          if (newWindow) window.open(location);
          else window.location.href = location || window.location.href; // vide recharge la même page
          this.WaitStateKeep = false; /* true laisse le picto visible quand l'utilisateur clique back */
        }, this);
        if (locDelayS && locDelayS.firstChild) window.setTimeout(locationChange, parseFloat(locDelayS.firstChild.nodeValue) * 1000);
        else locationChange();
      }
    }
    return success;
  },

The error is at first

  if (script) eval(script);
Gravatar is a globally recognized avatar based on your email address. re: Problem loading a form
  FoxInCloud Support - Thierry N.
  Michele
  Dec 29, 2021 @ 06:17am

Error occurs in the evaluated script, you can dig into it by several ways:

  • google chrome dev tools should provide a link to the offending line inside the evaluated script
  • choose break on all exceptions
  • find the script inside <script_>…</script_> tags in the server xml response when form displays
Gravatar is a globally recognized avatar based on your email address. re: Problem loading a form
  Michele
  FoxInCloud Support - Thierry N.
  Dec 29, 2021 @ 07:32am

I think that for this problem it should be usefull a remote session.... i am not able to make the controls you ask me

© 1996-2022