gerardocrisci Posted October 30, 2016 Share Posted October 30, 2016 What is the easiest way to update a UniLabel to display the time the client side. (No UniTimer) Some examples, please. Link to comment Share on other sites More sharing options...
Hayri ASLAN Posted October 30, 2016 Share Posted October 30, 2016 Add this code to Form.Onready UniSession.AddJS('(function () { '+ ' function checkTime(i) { '+ ' return (i < 10) ? "0" + i : i; '+ ' } '+ ' function startTime() { '+ ' var today = new Date(), '+ ' h = checkTime(today.getHours()), '+ ' m = checkTime(today.getMinutes()), '+ ' s = checkTime(today.getSeconds()); '+ ' document.getElementById('''+UniLabel1.JSName+'_id'').innerHTML = h + ":" + m + ":" + s; '+ ' t = setTimeout(function () { '+ ' startTime() '+ ' }, 500); '+ ' } '+ ' startTime(); '+ '})();'); Link to comment Share on other sites More sharing options...
gerardocrisci Posted October 30, 2016 Author Share Posted October 30, 2016 thank you UniLabel1.JSName+'_id' It is a safe definition of the name unigui components to javascript? but I used in ClientEvents.ExtEvents.Strings = ( function mouseout(sender, eOpts) { MainForm.UniLabel1.getEl().setStyle("font-weight","normal"); } function mouseover(sender, eOpts) { MainForm.UniLabel1.getEl().setStyle("font-weight","bold"); } } his name defined in the editor... MainForm.UniLabel1. Link to comment Share on other sites More sharing options...
cjmoore Posted October 25, 2018 Share Posted October 25, 2018 Hi Hayri, is it possible to to use your function to put the time into a specific TUniStatusbar panel eg Panel[1]? Using the above I can get the time onto the statusbar using the above (equivalent of setting statusbar.simpletext) but I can't see how display the value in a specific panel Link to comment Share on other sites More sharing options...
Sherzod Posted October 25, 2018 Share Posted October 25, 2018 Hi, Also you can use this approach too: UniStatusBar1 -> ClientEvents -> ExtEvents -> function afterrender: function afterrender(sender, eOpts) { var runner = new Ext.util.TaskRunner(), clockPnl, updateClock; clockPnl = sender.items.getAt(0); //UniStatusBar1.Panels[0] for example updateClock = function() { clockPnl.setHtml(Ext.Date.format(new Date(), 'g:i:s A')); }; sender._task = runner.start({ run: updateClock, interval: 1000 }); } Link to comment Share on other sites More sharing options...
cjmoore Posted October 25, 2018 Share Posted October 25, 2018 Perfect - thank you. Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now