Attach grid to form

Hey guys,

I’ve got a problem attaching a grid to a form.

These files are included:

[code]

[/code]

This is the xml file containing the form structure (important is the almost last line):

[code]<?xml version="1.0" encoding="UTF-8"?>

<item type="label" name="label_general" className="label_general" label="Allgemeines" inputWidth="600" />
	<item type="input" name="ref_number" className="ref_number" label="Nummer" inputHeight="18" inputWidth="100" />
	<item type="input" name="ref_name" className="ref_name" label="Bezeichnung" inputHeight="18" inputWidth="420" />
	<item type="input" name="dt_receipt" className="dt_receipt" label="Auftragseingang" inputHeight="18" inputWidth="100" />
	<item type="input" name="dt_site_survey" className="dt_site_survey" label="Besichtigung" inputHeight="18" inputWidth="100" />
	<item type="input" name="dt_completition" className="dt_completition" label="Fertigstellung" inputHeight="18" inputWidth="100" />
	<item type="input" name="dt_digitalized" className="dt_digitalized" label="Digitalisiert" inputHeight="18" inputWidth="100" />
	<item type="combo" name="_users_id_evaluator" className="_users_id_evaluator" label="Gutachter" inputWidth="210" connector="./lib/php/dhxComboConnector.php?dhx_sort[2]=asc&amp;comboID=obj_type" />
	<item type="combo" name="_val_types_id" className="_val_types_id" label="Bewertungsart" inputWidth="210" connector="./lib/php/dhxComboConnector.php?dhx_sort[2]=asc&amp;comboID=obj_type" />
	<item type="combo" name="_clients_id" className="_clients_id" label="Auftraggeber" inputWidth="210" connector="./lib/php/dhxComboConnector.php?dhx_sort[2]=asc&amp;comboID=obj_type" />
	<item type="combo" name="val_status" className="val_status" label="Status" inputWidth="210" connector="./lib/php/dhxComboConnector.php?dhx_sort[2]=asc&amp;comboID=obj_type" />
	<item type="input" name="remark" className="remark" label="Bemerkung" rows="14" inputHeight="215" inputWidth="310" />

<item type="label" name="label_object" className="label_object" label="Objekt" inputWidth="600" />
	<item type="combo" name="obj_type" className="obj_type" label="Objektart" inputWidth="210" connector="./lib/php/dhxComboConnector.php?dhx_sort[2]=asc&amp;comboID=obj_type" />
	<item type="combo" name="obj_subtype" className="obj_subtype" label="Nutzungsart" inputWidth="210" connector="./lib/php/dhxComboConnector.php?dhx_sort[2]=asc&amp;comboID=obj_type" />
	<item type="input" name="obj_area" className="obj_area" label="Fl&#228;che (m&#178;)" inputHeight="18" inputWidth="100" />
	<item type="input" name="obj_std_grnd_value" className="obj_std_grnd_value" label="BRW (&#8364;/m&#178;)" inputHeight="18" inputWidth="100" />
	<item type="input" name="obj_street" className="obj_street" label="Stra&#223;e" inputHeight="18" inputWidth="307" />
	<item type="input" name="obj_zip" className="obj_zip" label="PLZ" inputHeight="18" inputWidth="85" />
	<item type="input" name="obj_city" className="obj_city" label="Ort" inputHeight="18" inputWidth="212" />
	
<item type="label" name="label_renter" className="label_renter" label="Mieter" inputWidth="600" />
	<item type="input" name="renter_area" className="renter_area" label="Fl&#228;che (m&#178;)" inputHeight="18" inputWidth="100" />
	<item type="input" name="renter_fee" className="renter_fee" label="Miete (&#8364;/m&#178;)" inputHeight="18" inputWidth="100" />
	<item type="input" name="renter_name" className="renter_name" label="Mieter" inputHeight="18" inputWidth="310" />
	
<item type="label" name="label_files" className="label_files" label="Dateiverwaltung" inputWidth="600" />	
	<item type="container" name="grid_files" className="grid_files" inputWidth="330" inputHeight="200" />

[/code]

That’s an extract of the page where the grid should appear in:

<script type="text/javascript">
        	/* common */
        	var dhxLayout;
        	var dhxMenu;
...
        	/* cell c */
        	var dhxToolbarDetails;
        	var dhxFormDetails;
...

		dhtmlxEvent(window, "load", function(){
			/* dhxLayout - cell a - dhxFormSearch */
			dhxFormDetails = new dhtmlXForm("dhxFormDetails");
			dhxFormDetails.setFontSize("inherit");
			dhxFormDetails.loadStruct("./lib/xml/dhxFormDetails.xml?etc=" + new Date().getTime(), function(){
				/* do on form load */
						
				/* disable browser completition */
				dhxFormDetails.forEachItem(function(id){
					if (dhxFormDetails.getItemType(id) == "input") {
						dhxFormDetails.getInput(id).autocomplete = "off";
					}
				});	
			});
					
			/* attach dhxGridFiles */
			var grid_files = dhxFormDetails.getContainer("grid_files");
			console.log("grid_files: "+grid_files);
		}

The console.log is 'null", so there is no handle to the container. Could you explain why, please? I don’t see the reason.

Thank you…

Hi
You need to get form container in callback
Something line

myForm.loadStruct("form.xml", function(){ var grid_files = dhxFormDetails.getContainer("grid_files"); });

Hi Darya,

this works perfectly great. Thank you so much!

Cheers, Andreas

You are welcome!