Table displaying data and time


Recommended Posts

I want to have a table component display my channel's data, including time.

Doing it this way, I get the value of the channel readings right, but the time is not being displayed. What I want is to display it as it's displayed on the channels' table.

page.Leituras.Component.tabelahistorico.ClearColumns()

private string chanlist = channel.ListAll()
for(private.i=0, i < numrows(chanlist), i++)
   private string chanparse = parse(chanlist[i],-1,"_")
   if(chanparse[1] == curnet)	  
	  if(chanparse[2] == dev)			  
		 page.Leituras.Component.tabelahistorico.AddColumn("formatdatetime('%d/%m/%Y %H:%M:%S', evaluate(chanlist["+i+"].gettime())", 'Data',150)
		 page.Leituras.Component.tabelahistorico.AddColumn(evaluate("chanlist["+i+"]"), evaluate("chanparse[0]"))
	  endif
   endif
endfor

Channels are named: var_curnet_dev

I wonder if I can get the time using evaluate like this. Also I would like to display only one time column, only cycling in the channels for the variables, any thoughts?

Link to comment
Share on other sites

You don't need to use evaluate here and in fact you are using it incorrectly for the time column as you are basically putting the evaluate() function directly into the table column which means evaluate() is called by the table, not your script and chanlist is a private to the script. Also you are using GetTime() incorrectly. It is a global function like sin() or cos(), not a member function of the channel. Also, just fyi, you don't have to do page.leituras, you can just to Component. as long as the table name is unique across all pages. Here's the correct format:

component.tablehistorico.addcolumn("formatdatetime('%d/%m/%Y %H:%M:%S',GetTime("+chanlist[i]+"))", 'Data', 150)

component.tablehistorico.addcolumn(chanlist[i], chanparse[0])

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.