<item type="select"> inside a form bind to grid field

Hello, I’m trying to bind the value of an of a form with a grid’s field (id_user) linked to mysql table.

form.xml

	<item type="select"  label="Valutatore" name="id_valutatore" offsetLeft="10">

when I select a row in grid I want the Label of select tag changing according to corresponding value in xml file.

option.xml

<?xml version="1.0" ?>
<complete>
	<option value="1">Name 1</option>
	<option value="2">Name 2</option>
	<option value="3">Name 3</option>
	<option value="4">Name 4</option>
</complete>

And when I save the form I want to save the value of option to id_user field.

Thanks for your help

Hello
Do you use DataStore component?

No I don’t !!

I use GridConnector.

You can try the next approach:

var newData = []; var gridData={ rows:[ { id:1001, data:[ "100", "A Time to Kill", "John Grisham"]}, { id:1002, data:[ "1000", "Blood and Smoke", "Stephen King"] }, { id:1003, data:[ "-200", "The Rainmaker", "John Grisham"], selected: true }, { id:1004, data:[ "350", "The Green Mile", "Stephen King"]} ]}; var formData = [ {type: "select", name: "selectItem", value: "", inputWidth: 200, labelWidth:100, label: "Select"} ]; function doOnLoad(){ mygrid = new dhtmlXGridObject('gridbox'); mygrid.setImagePath("../dhtmlxSuite_v41_pro/codebase/imgs/"); mygrid.setHeader("Sales, Book Title, Author"); mygrid.setInitWidths("70,250,*"); mygrid.setColAlign("right,left,left"); mygrid.setColTypes("dyn,ed,ed"); mygrid.init(); mygrid.parse(gridData,"json"); myform = new dhtmlXForm("formbox", formData); mySelect = myform.getSelect("selectItem"); for (var i=0; i<mygrid.getRowsNum(); i++){ var selectData = mygrid.cellById(mygrid.getRowId(i),1).getValue(); newData = newData.concat({text: selectData, value: selectData}); myform.reloadOptions("selectItem", newData); } myform.setItemValue("selectItem", mygrid.cellById(mygrid.getSelectedRowId(),1).getValue()); mygrid.attachEvent("onRowSelect", function(id,ind){ var val = mygrid.cellById(id,1).getValue(); myform.setItemValue("selectItem", val); }); }

Ok, thanks.

I used another approach, I named the select item of the form like the grid’s field (sic = sic).

attrezzatureGrid.setColumnIds("sic,name,surname");
<item type="select" label="Reparto" name="sic" offsetLeft="10">
   <option value="01" label="Laboratorio"/>
   <option value="02" label="Accettazione"/>
   <option value="03" label="Chimica"/>
</item>

So when I select a grid’s row the form’s item (named sic) change !!
Is it the because data binding between form and grid ??

Please, attach completed demo on support@dhtmlx.com
docs.dhtmlx.com/auxiliary_docs__ … pport.html

I attach my demo.

I use a database, database dump file is in db folder.
username: admin
password: admin

Now the select item is working correctly. It’s bind to SIC field. The form it’s not complete.
my_lims.rar (1.3 MB)

Hi

demo is ok. please provide steps to reproduce with current behaviour and awaited behaviour?

Thank you for your reply, The binding between database field and combobox it’s ok.
When I select a row in grid with a (reparto_id) field, combo show the right label (taken from reparti.xml).

Now, I would like to have only read combo (this doesn’t work) for searching an item in reparti.xml file and then put the corresponding value in database field (reparto_id) (this actually works).

form.xml

<item type="combo" label="Reparto" name="id_reparto" offsetLeft="10"/>

reparti.xml

<?xml version="1.0" ?> <complete> <option value=""></option> <option value="01306">Reparto 1</option> <option value="00999">Reparto 2</option> <option value="00996">Reparto 3</option> </complete>

Thanks for any help and have an

:smiley: Happy New Year :smiley:

Dear netsam,

“please provide steps to reproduce with current behaviour and awaited behaviour” means the following reply from you:

  1. open application
  2. switch to tab xxx, here you see grid yyy with combo zzz
  3. type some text into combo, see window appear? should be popup.
  4. the question is how to change window to popup?

in blue - current behaviour, in green - awaited behaviour, number 4 - question. this is what we waiting from you. more details - better and quicker answer.