When you deal with multiple related components on client-side, you can define rules how their data will be linked. So changed value in some component will be reflected in other components.
There are 2 main ways to link data:
In both cases, based on configuration:
Basically, you can load data just once, in single global data store and define rules, how different components will use it.
Functionality described above can be applied to the following components:
barChart.sync(data);
mycombo.sync(data);
mycombo.bind(mygrid);
mycombo.dataFeed("data/combo.php");//specify here the path to a file which will get change requests mycombo.bind(myview);
myview.sync(data);
myview.bind(grid);
myview.dataFeed("data/dataview.php");//specify here the path to a file which will get change requests myview.bind(myform);
myform.bind(data);
myform.bind(mygrid);
Beware, for correct running you should specify the same IDs for grid columns and form controls:
myGrid.setColumnIds("col1, col2, col3"); var formData = [ {type: "input", name:"col1"}, {type: "input", name:"col2"}, {type: "input", name:"col3"} ] myform = new dhtmlXForm("box", formData);
myform.dataFeed("data/form.php");//specify here the path to a file which will get change requests myform.bind(mygrid);
myform.bind(mygrid); myform.attachEvent("onButtonClick", function(id){ myform.save() //will push updates back to the master list });
mygrid.sync(data);
mygrid.sync(data); mygrid.attachEvent("onRowSelect", function(id){ data.setCursor(id); }); myform.bind(data);
mygrid.bind(myCombo, function(data, filter){ return myGrid.cells(data, 2).getValue() == filter.text; });
mygrid.dataFeed("data/grid.php"); //specify here the path to a file which will get change requests) and it will help you to load new data from the server (instead of the master component) mygrid.bind(myform, function(master, data){ if (master.Name == "") return true; return mygrid.cells(data, 1).getValue().toLowerCase().indexOf(master.Name)!=-1; }); //each time, when some value in form is changed, //grid will be filtered, based on defined logic
mytree.bind(myview);
mytree.dataFeed("data/tree.php"); mytree.bind(mygrid);
Components which are used as source of bind operation receive few extra events and API commands, which allow to push data in slave components.
You can use
mygrid.setCursor(id)
to force loading of necessary data in all components, which use grid as master control.
and
var id = mygrid.getCursor()
to get current position of cursor.