Solution for Data grid with 2 or more colums solution in Plua

Hello again! I has partially solve my problem adapting a suggestion posted by Morten Agerlin Petersen on Plua official mail-list. But I not use "gui.field", I use multiple "gui.list", one for each data colum in the data passed to function.

See here the code developed (isn't a better code... but work)

-- tool to easy display multi colums data using Plua

function eventsHandler(e, id, arg)

 --print("e"..e.." id"..id.."arg"..arg)

 -- incredible bad code here !

 -- dont make this in your house please :)
 gui.setstate(1800,arg) 

 gui.setstate(1801,arg) 
 gui.setstate(1802,arg) 


end

function datagrid(data,lines,colums,height,widthColums)

 d={}
 x = 0
 for j=1, colums do

  for i=1, lines do

   d[i] = data[i][j]
  end

  screen.moveto(x)

  x = x + (widthColums[j]*5) +1

  list = gui.list(height,widthColums[j],d)

  gui.sethandler(list,eventsHandler)
 end

end


-- testing ------------------------------------

mydata = {}
for a=1,30 do

 mydata[a] = {}
 mydata[a][1] = a;
 mydata[a][2] = "description "..a;

 mydata[a][3] = "value "..a;

end

screen.moveto(0,30)

gui.title("Data grid with >= 2 colums")

widthColums = {}

widthColums[1] = 5
widthColums[2] = 18

widthColums[3] = 8

-- data, lines,colums, height, width for each colum of matrix

datagrid(mydata,30,3,12,widthColums)


gui.main()

This example create a 3 colums (of lists) in the screen, the position of each is adjusted to appear as if it were a single component.

Again it is not a best but I will work with what I have.

Thanks for all friends.
2009-05-31 13:07:00
Computers and science as a way to live

As you may know, I`m a programmer, I work most in web projects, but not only. This area is a mess! Each day you have to recycle what you know in many ways. The thing is, a knowledge that change so often can`t afford wait to be translated to Portuguese for instance, at that time, the known will be already deprecated. English to me is a functional requirement. I can`t imagine my daily life without it. I have been studding English for serious since 2009. In this section you can see what I`m working on. Have fun as I do.
RSS Feed
"A vida é curta demais para ser pequena / The live is so short to be small / Das leben zu kurz sind für kleine sein". (Benjamin Disraeli)