Jump to content

Table -|- Gridlist [Help]


Recommended Posts

It's creating a random row instead of all the rows? Is that what you mean?

edit; tested the code and it works normal for me buddy. How are you filling the 'vehicleTypeGrid' ? are you using the first item in the array for that?

Edited by Guest
Link to comment

I took your code under a quick scope and made the other parts with some rubbish code, but it works for me this way;

vehicleTypeGrid = guiCreateGridList ( 400, 200, 150, 300, false ); 
vehicleGrid = guiCreateGridList ( 600, 200, 250, 300, false ); 
column = guiGridListAddColumn( vehicleGrid, "Vehicle", 0.85 ) 
column = guiGridListAddColumn( vehicleTypeGrid, "Type", 0.85 ) 
  
row = guiGridListAddRow ( vehicleTypeGrid ) 
guiGridListSetItemText ( vehicleTypeGrid, row, 1, "Cars", false, false ) 
  
addEventHandler ( "onClientGUIClick", root, 
    function() 
        if ( source == vehicleTypeGrid ) then 
            local row, col = guiGridListGetSelectedItem(source) 
            if row and col and row ~= -1 and col ~= -1 then 
                local category = guiGridListGetItemText(source, row, 1) 
                guiGridListClear ( vehicleGrid ) 
                if ( vehicleCategory [ category ] ) then 
                    for _, veh in ipairs ( vehicleCategory [ category ] ) do 
                        local row = guiGridListAddRow ( vehicleGrid ) 
                        guiGridListSetItemText ( vehicleGrid, row, 1, veh [ 2 ], false, false ) 
                        guiGridListSetItemData ( vehicleGrid, row, 1, veh [ 1 ] )    
                    end 
                end 
            end 
        end 
    end 
) 

Link to comment
    local row = guiGridListAddRow ( vehicleTypeGrid ) 
    guiGridListSetItemText ( vehicleTypeGrid, row, 1, "Aircraft", false, false ) 
    guiGridListSetItemText ( vehicleTypeGrid, row, 2, "Bikes", false, false ) 
    guiGridListSetItemText ( vehicleTypeGrid, row, 3, "Boats", false, false ) 
    guiGridListSetItemText ( vehicleTypeGrid, row, 4, "Cars", false, false ) 
    guiGridListSetItemText ( vehicleTypeGrid, row, 5, "Emergency", false, false ) 

Im try this but it's not work... It's a only add 1 row.

36cj6ezs.png

Link to comment

This can also be a way for you;

local categories = { "Aircraft", "Bikes", "Boats", "Cars", "Emergency" } 
  
for _, r in ipairs ( categories ) do 
    local row = guiGridListAddRow ( vehicleTypeGrid ) 
    guiGridListSetItemText ( vehicleTypeGrid, row, 1, r, false, false ) 
end 

it might be even better because if you are going to add ( as example ) 50 categories, you don't have to create 50 rows of these;

Just do:
guiGridListSetItemText(gridlist, guiGridListAddRow(gridlist), columnid, rowtext, section, number) 

No offense, :oops:

Link to comment
This can also be a way for you;
local categories = { "Aircraft", "Bikes", "Boats", "Cars", "Emergency" } 
  
for _, r in ipairs ( categories ) do 
    local row = guiGridListAddRow ( vehicleTypeGrid ) 
    guiGridListSetItemText ( vehicleTypeGrid, row, 1, r, false, false ) 
end 

it might be even better because if you are going to add ( as example ) 50 categories, you don't have to create 50 rows of these;

Just do:
guiGridListSetItemText(gridlist, guiGridListAddRow(gridlist), columnid, rowtext, section, number) 

No offense, :oops:

Thank you tosfera. It's solved :lol:

Link to comment
This can also be a way for you;
local categories = { "Aircraft", "Bikes", "Boats", "Cars", "Emergency" } 
  
for _, r in ipairs ( categories ) do 
    local row = guiGridListAddRow ( vehicleTypeGrid ) 
    guiGridListSetItemText ( vehicleTypeGrid, row, 1, r, false, false ) 
end 

it might be even better because if you are going to add ( as example ) 50 categories, you don't have to create 50 rows of these;

Just do:
guiGridListSetItemText(gridlist, guiGridListAddRow(gridlist), columnid, rowtext, section, number) 

No offense, :oops:

True ;)

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...