undefined Posted July 17, 2014 Posted July 17, 2014 (edited) Hi guys. Im work on the new freeroam panel. Gridlist as in table row not doing. It's make random row. And my code: Code Removed How to fix it? Edited July 17, 2014 by Guest
tosfera Posted July 17, 2014 Posted July 17, 2014 (edited) 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 July 17, 2014 by Guest
undefined Posted July 17, 2014 Author Posted July 17, 2014 It's creating a random row instead of all the rows? Is that what you mean? Yes. It's create random row. But I want to do according to the table row.
tosfera Posted July 17, 2014 Posted July 17, 2014 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 )
undefined Posted July 17, 2014 Author Posted July 17, 2014 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.
tosfera Posted July 17, 2014 Posted July 17, 2014 For every row ( line ) you want to insert, you have to create a new row. So for 'Aircraft', 'Bikes', 'Boats', you need 3 rows. So you got 5 different types, so you have to add 5 new rows.
Et-win Posted July 17, 2014 Posted July 17, 2014 Just do: guiGridListSetItemText(gridlist, guiGridListAddRow(gridlist), columnid, rowtext, section, number)
tosfera Posted July 17, 2014 Posted July 17, 2014 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,
undefined Posted July 17, 2014 Author Posted July 17, 2014 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, Thank you tosfera. It's solved
tosfera Posted July 17, 2014 Posted July 17, 2014 Also know why it got solved? Because if you don't you'll make the same mistake again haha. ^^
Et-win Posted July 17, 2014 Posted July 17, 2014 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, True
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now