formatting form fields

Hi,
now you should attach events insertCallback, updateCallback, deleteCallback which will be called when some update from server was downloaded:

form.attachEvent("updateCallback", function() {
    console.log("Form data was updated by someone else!");
});

DataProcessor doesn’t provide blocking form from editing automatically.

Many thanks

Only a question again.

In the documentaion: http://docs.dhtmlx.com/doku.php?id=dhtmlxconnector:multi_sync&s[]=sync
I didn’t find reference to this functions to complete the multi-sync functionality.

Can i also use this callback Function in the same way without enabling multi-sync, or is there something that i don’t understand ?

Thanks

Hi,

I try to attach this event “updateCallback” as you suggested but nothing happens like before. I try to attach it to the form and also to Dataprocessor with the same no-result.

I confirm that i didn’t find any reference to these Callback functions in the Documentation. Where can i find them ?

Hi,
could you provide complete demo or link to your project (this would be the best way)?

Sorry but i haven’t a site. I’m an hobbist and i work locally.
I will try to bild a demo but there is nothing particular to verify. I followed exactly what is explained in the documentation example. The problem, i think, is your last suggestions about Callback functions that has not reference on your site. Could you tell me where is the documentation about these functions so i can understand much more and do experiments on my own.

Thanks

Hi,
this events aren’t described in documentation, but they are in code (dhtmlxdataprocessor.js, the best way would be to see this code in not-compressed file):

	loadUpdate: function(){
		var self = this;
		var version = this.obj.getUserData(0,"version");
		var url = this.serverProcessor+getUrlSymbol(this.serverProcessor)+["dhx_user="+this._user,"dhx_version="+version].join("&");
		url = url.replace("editing=true&","");
		this.getUpdates(url, function(){
			var vers = self._loader.doXPath("//userdata");
			self.obj.setUserData(0,"version",self._v(vers[0]));
			
			var upds = self._loader.doXPath("//update");
			if (upds.length){
				self._silent_mode = true;
				
				for (var i=0; i<upds.length; i++) {
					var status = upds[i].getAttribute('status');
					var id = upds[i].getAttribute('id');
					var parent = upds[i].getAttribute('parent');
					switch (status) {
						case 'inserted':
							self.callEvent("insertCallback",[upds[i], id, parent]);
							break;
						case 'updated':
							self.callEvent("updateCallback",[upds[i], id, parent]);
							break;
						case 'deleted':
							self.callEvent("deleteCallback",[upds[i], id, parent]);
							break;
					}
				}
				
				self._silent_mode = false;
			}
			
			self._update_busy = false;
			self = null;
		});
	}

And I did a mistake - event must be attached to dataprocessor object, not to the form.

Many thanks again.

I just tried to attach this event to dataProcessor but nothing:

this is an extract from my code about the form and related events.

index.html


contactForm = layout.cells(“b”).attachForm();
contactForm.loadStruct(“xml/form_iter.xml”);
contactForm.lock();
contactsGrid.attachEvent(“onRowSelect”, function(rID,cInd){
contactForm.unlock();
contactForm.load(“php/Prova_form.php?id=”+rID);
});
contactForm.attachEvent(“onChange”,function(){
cambio=1
});
contactForm.attachEvent(“onBeforeDataLoad”,function(id, values){
if(cambio==1){
if(confirm(“Modifiche non salvate! Uscire senza salvare ?”)){
cambio=0;
return true;}
else {
return false;};
}
else {
return true;};
});
var dpf = new dataProcessor(“php/FidiPrivati_formUPD.php”);
dpf.init(contactForm);
dpf.setAutoUpdate(2000);
dpf.attachEvent(“updateCallback”, function() {
alert(“I Dati sono stati modificati da altro Utente”);
});
dpf.attachEvent(“onAfterUpdate”,function(sid,action,tid,xml_node){
contactsGrid.cells(sid,0).setValue(contactForm.getItemValue(“ESITO_CHECK”));
});
contactForm.attachEvent(“onButtonClick”, function(name, command){
if(cambio==0){
alert(“nessun dato/modifica da salvare”);}
else {
cambio=0
dpf.sendData();};
});

Prova_form.php

<?php require("../codebase/connector/form_connector.php"); $res=mysql_connect("localhost","root","root"); mysql_select_db("dbprova"); $formConn = new FormConnector($res); $formConn->enable_live_update('actions_table'); $formConn->render_table "Mastertable","idMasterTable","Field1,Field2,Field3,Field4,idMasterTable"); ?>


I hope you’ll find the mystery i’m going crazy.

Many Many thanks.

Hi,
you code looks correctly.
Please, provide a complete demo (including all required files and database dump with test data) to get it to work at local machine.

Hi to everybody.

At the end i built the attached complete demo starting from one of your examples.
I used your Tutorial with your DB contacts adding only one new Field, called ‘NUMERO’ as double, to store an example number.

The problems that i’d like to solve are:

  1. As specified in my previous post, multi-sync user doesn’t run. When i position two computers of the local lan on the same record (in form), saving modifications from the first pc, i don’t receive the message from the Event UpdateCallback when i save the same record on the 2nd computer!

  2. the other problem is about number formatting. You can see the “numero” definition. in FORM.XML where i set the group-separator to ‘.’ an decimal separator to ‘,’. The number string definition is “0,000” without decimals. In this situation if i write the number 1200 the fields shows correctly 1.200 but when i save in the DB i have 1,2 and when i refresh the form i have 1 in the form field.
    The strange thing is that if define the number string definition as “0,000.00”, all seems run correctly and the DB too, but i don’t want decimals.

Thanks a lot as always.demo.zip (731 KB)

Hi,
please, provide also dump of all required database tables with some test data. I can’t find it in demo.

Hi Radyno,

As i said in my previous post that to avoid the problem to dump database, i used YOUR DB, whose sql definition query is included in your Tutorial, so you should just have it.

The only user table that i used is CONTACTS, adding only one row named “NUMERO”, defined as DOUBLE in mysql, to show the problem about number formatting. The only other table is “actions_table” that i defined as specified in your documentation.

I don’t think to have anything else to attach.

Thanks

Hi,
I did some tests and unfortunately multi-user sync doesn’t suppoerted by dhtmlxForm.
It was designed only for components which store a lot of items.

It’s a real pity !

  • Any idea to implement through the various event available ?

I’ve also another question about an other aspect of the suite:

I would like to built a kind of Pivot table like you can see in the attached Excel Sheet and i’d like to built through treeGrid

I built a view in MySQL that show data as in the attached sheet but i didn’t understand yet how to define the render_table function.
These are the questions:

  • Can i use the view as it was a table, using render_table or i’ve to use render_sql as it was a query ?

  • Can you explain the sintax of render_table to obtain the pivot that i attached ? Following the examples in documentation i didn’t obtain results.

  • have i to use treeGridConnector or treeGridGroupConnector ?

  • Is it better to use a single table/view like i did or is it better to use treeGridMultiTableConnector defining different query for each level even if coming from the same table ?

I’ll never stop to thank you for your help and patience.VIEW.zip (6.41 KB)

Hi,
Unfortunately there is no way to implement multi-user sync for form (actually it’s possible, but it will take really a lot of work).

The best way would be to create a view, which stores data like here:
id | column1 | column2 | column3 | parent_id

Then you may use usual TreeGridConnector to select data from your view using render_table.

OK Thanks

One last thing. What about the problem in formatting number that i described in the post with demo. ?

Bye

Hi

One last thing. What about the problem in formatting number that i described in the post with demo. ?

Try to update your files to 3.6 version - it must fix your issue.