Live update problem ...

Hi,
I’m trying “live update” with grid and dataprocessor . Following this steps - localhost:8008/sync.js . To what that related ? Form description : sync.js (a file located on the Node.js server). But this file exist only in “nodejs\node_modules\npm\node_modules\mkdirp\test” directory . “test” directory ?

Please , help in this situation … With best regards ! Rimantas

Forget this . Simply started node server at first time I closed command prompt window . It closed and server . Now I tried again , leaved cmd open . No errors .

How to check on the same PC , how live update is working ?
I tried with one small grid , added this : myDp.live_updates( “http://localhost:8008/sync” );
Then run the grid on chrome and IE9 . Did changes in IE9 … sorry , but nothing changes in Chrome … :open_mouth:

Another question - how to avoid cmd window for nodejs server ? Can this be started with Apache server ? I’m using wamp.

Thanks in advance !

Hi again,
found solution , how to run nodejs as windows service : blog.tatham.oddie.com.au/2011/03 … n-windows/

Folowwing to this I did that ( bat file ) :
set PATH=C:\Program Files\nodejs\npm;%~dp0;%PATH%
nssm.exe install lv_up-node C:\Program Files\nodejs\node.exe d:\wamp\www\nodejs\server.js
net start lv_up-node

It did half of work - create service , but can’t to start . It return error :
A service specific error occurred: 3
More help is available by typing NET HELPMSG 3547

Maybe somebody know more about that error ? Any idea ?

With best regards ! Rimantas

Forget it … :smiley:

Simply do from cmd : “nssm install yourservicename” and then direct node.exe and options ( in mine case c:\program files\nodejs\node.exe and d:/wamp/www/nodejs/server.js ) . All is working fine … Now I’m getting fully functional live update … :slight_smile:

Another question will be - how to check is running “live_update” service or not ? Can this be done ?

With best regards !

You may open the same grid in two browser tabs and change data in one of them. It must be updated in another at the same time.

Woww ! :smiley: How fine ! Maybe it was something wrong , that not did at first time. Now I tried - working very fine . On the same browser , with diff browser works fine too . Cool ! :smiley:

Many thanks !

Though “live update” is working fine , mine question is related to other thing . Let say that “LiveUpdate” service ( server ) stops and user don’t know about that . How to catch error of myDp.live_updates( “http://127.0.0.1:8008/sync” ); ? And show warning in the screen “Your live update isn’t working !!!” ? Can this be done ?

With best regards !

Strange … All updates all the same grids ( on dif tabs or on difs browsers ) are seeing . But I surprised that other grids aren’t seeing new added rows … :open_mouth: Why ?

It’s more clear now … :slight_smile: Update and delete actions are visible , only insert action isn’t visible . I’m adding new records from from :

         myForm.attachEvent( "onButtonClick", function( id ) 
         {
            if ( myForm.validate() )
            {
               var cNew  = myForm.getItemValue( 'mod_grp' ).toUpperCase();
               var cFlds = "prek_grupe,prek_tipas,pav_lt,pav_en,db";
               var cVars = "'" + cNew + "','Gaminys','" + 
               myForm.getItemValue( 'pav_lt' ) + "','" + 
               myForm.getItemValue( 'pav_en' ) + "','" + $app_db + "'";
               var loader = dhtmlxAjax.getSync( "lent_new.php?tbl=prekiu_grupes&fld=" + cFlds + "&nvr=" + cVars );
               if ( loader.xmlDoc.responseText == "true" )
               {
                  w1.close();
                  mygrid.clearAll();
                  mygrid.load( cQry,function(){ mygrid.selectRowById( cNew ); } );
                  return true;
               }
               else
                  alert( loader.xmlDoc.responseText );
            }      
         });

So how I can to let to know for “live update” that “insert” action is from form ?

With best regards !

Hi,
there is no way to know that connection is down out-of-box but you may customize file live-updates.js:

lu.client = new Faye.Client(url);
lu.bind('transport:down', function() {
    // connection is down
});

Also you may modify your code like here:

this.changed = function(sid, action, tid, tag){
	var item;
	if (self.obj.exists(sid))
		item = self.obj.item(sid);
	else
		item = {};

	if (typeof(item.$selected) !== 'undefined') delete item.$selected;
	if (typeof(item.$template) !== 'undefined') delete item.$template;
	lu.client.publish('/broadcast', { sid: sid, tid: tid, status: action, data: item });
};
this.attachEvent("onAfterUpdate", this.changed);

Now you may call

dataprocessor.changed(old_id, "inserted", new_id);

to tell that it was changed.

Thanks radyno , for your answer . I leaved this question in DataProcessor discusion and Stanislav answered to me . Stanislav’s solution :

                  w1.close();
                  mygrid.clearAll();
                  mygrid.load( cQry, function(){ mygrid.selectRowById( cNew ); myDp.callEvent( "onAfterUpdate", [ cNew, "insert", cNew ] ); } );
                  return true;

It’s working . For newbie like me :slight_smile: , it’s more easy … Maybe it will be needful in future , then I’ll be more experience in javascript … :smiley:

With best regards !