netsam
December 3, 2014, 7:22pm
#1
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
Darya
December 5, 2014, 2:17pm
#2
Hello
Do you use DataStore component?
Darya
December 10, 2014, 2:53pm
#4
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);
});
}
netsam
December 12, 2014, 9:47pm
#5
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 ??
Darya
December 15, 2014, 2:45pm
#6
netsam
December 16, 2014, 9:16pm
#7
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)
Andrei
December 22, 2014, 2:51pm
#8
Hi
demo is ok. please provide steps to reproduce with current behaviour and awaited behaviour?
netsam
December 30, 2014, 5:25pm
#9
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
Happy New Year
Andrei
January 6, 2015, 2:18pm
#10
Dear netsam,
“please provide steps to reproduce with current behaviour and awaited behaviour” means the following reply from you:
open application
switch to tab xxx, here you see grid yyy with combo zzz
type some text into combo, see window appear? should be popup.
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.