Jump to content

GridList


_Marco_

Recommended Posts

You can try something like this

dxGridList = {
    x = 0,
    y = 0,
    width = 300,
    height = 200,
    columns = {},
    rows = {}
}

addColumn = function(name,size)
    table.insert(dxGridList.columns,{name,size});
end

addRow = function(col,value)
    table.insert(dxGridList.rows,{col,value});
end

local sx,sy = guiGetScreenSize();

addEventHandler("onClientRender",root,function()
    local x,y = sx/2-dxGridList.width/2,sy/2-dxGridList.height/2;
    local w,h = dxGridList.width,dxGridList.height;
    dxDrawRectangle(x,y,w,h,tocolor(70,70,70));
    local colx = x;
    dxDrawRectangle(x,y,w,25,tocolor(10,10,10))
    for i,col in ipairs(dxGridList.columns)do
        local cw = col[2]*w;        
        dxDrawText(col[1],colx,y+4,100,20,tocolor(255,255,255),1,"default");
        local ry = y+20;
        for j,row in ipairs(dxGridList.rows)do
            if(row[1] == i)then
                dxDrawRectangle(colx,ry,cw,20,tocolor(120,120,120))
                dxDrawText(row[2],colx,ry,100,20,tocolor(255,255,255),1,"default");
                ry = ry + 20;
            end
        end
        colx = colx+cw;
    end
end);

addColumn("Col 1",.1);
addColumn("Col 2",.7);
addColumn("Col 3",.2);

for i=1,20 do
    addRow(math.random(1,3)," "..tostring(i));
end

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...