Datagrid Check boxes
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Datagrid Check boxes
Hi All
I'm trying to to work out how to code a button that if pressed will check the check box of each row that is displayed in my datagrid. If i press another button then the check box of each row in the datagrid needs to uncheck.
Your help is most appreciated!
I'm trying to to work out how to code a button that if pressed will check the check box of each row that is displayed in my datagrid. If i press another button then the check box of each row in the datagrid needs to uncheck.
Your help is most appreciated!
Re: Datagrid Check boxes
easy...
Code: Select all
repeat with i = 1 to the number of buttons of group "Campaign"
set the highlight of button i of group "Campaign" to true
end repeat
Re: Datagrid Check boxes
Here is a small sample, with check boxes.
- Attachments
-
- TESTDATAGRID.zip
- (7.62 KiB) Downloaded 325 times
Re: Datagrid Check boxes
Great thanks you for that. I was hoping the datagrid example would show how to filter the records with checked check boxes. I have around 400 records in my datagrid and want it to display just the records that have checked check boxes.
Is this easy enough?
I have looked at every single datagrid lesson and none of them explain how to do this...
Is this easy enough?
I have looked at every single datagrid lesson and none of them explain how to do this...
Re: Datagrid Check boxes
In this case, it's different.bsouthuk wrote:Great thanks you for that. I was hoping the datagrid example would show how to filter the records with checked check boxes. I have around 400 records in my datagrid and want it to display just the records that have checked check boxes..
-1 put the content of your grid in a var
-2 analyse each line, with a repeat loop, look for a flag (in my example, the column "status"), and build a new var with the lines that contain the flag
-3 put the new var into your grid. et voila !
So it could be :
1-
put the dgText of group "myDataGrid" into theContent
2-
set itemdelimiter to tab
put empty into theFilteredContent
repeat with i = 1 to the number of lines of theContent
if item 2 of line i of theContent = "1" then put line i of theContent & CR after theFilteredContent ---- here the column "status" is the item number 2
end repeat
3-
put false into pFirstLineContainsHeaders
set the dgText [ pFirstLineContainsHeaders ] of group "myDataGrid" to theFilteredContent
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Contact:
Re: Datagrid Check boxes
A while back I wrote up a blog post on filtering datagrids which you might want to check out.
HTH,
Jan Schenkel.
HTH,
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
Re: Datagrid Check boxes
Thats great but how do I set the text to '1' if the check box is checked?
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Contact:
Re: Datagrid Check boxes
I've added a lesson to the Data Grid manual that shows how to work with checkboxes in a data grid. At the end of the lesson there is an example of checking/unchecking every row. Let me know if this helps clear things up.
http://lessons.runrev.com/spaces/lesson ... Data-Grid-
http://lessons.runrev.com/spaces/lesson ... Data-Grid-
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
Re: Datagrid Check boxes
Thank you so much for this, its exactly what I need, however my datagrid has to be a table but the datadrid breaks if I change it from Form. Why is this?
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Contact:
Re: Datagrid Check boxes
When you switch to "table" you won't have columns named "label" and "checked" so the data in the dgData array that is assigned to the data grid has no columns to display the values.
Try adding two colums (or renaming any existing ones) to "label" and "checked". Then both buttons will work again, although you won't have a checkbox displayed. You would need to go back and customize the "checked" column to contain a checkbox.
Try adding two colums (or renaming any existing ones) to "label" and "checked". Then both buttons will work again, although you won't have a checkbox displayed. You would need to go back and customize the "checked" column to contain a checkbox.
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
Re: Datagrid Check boxes
Thanks Trevor. Am getting close here but the datagrid is returning the following error message:
OBJECT Value is not a boolean (true or false) for line: set the hilited of button "Check" of me to pDataArray["checked"]
This has only happened when I have changed from Form to Table.
Also, I need a a button that allows me to select all or deselects all check boxes in the datagrid. Sometimes there can be 100's of records in the datagrid and when the check box is checked it needs to display as true and false when not selected.
Could you possibly supply me with this code please?
Thank you
Daniel
OBJECT Value is not a boolean (true or false) for line: set the hilited of button "Check" of me to pDataArray["checked"]
This has only happened when I have changed from Form to Table.
Also, I need a a button that allows me to select all or deselects all check boxes in the datagrid. Sometimes there can be 100's of records in the datagrid and when the check box is checked it needs to display as true and false when not selected.
Could you possibly supply me with this code please?
Thank you
Daniel
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Contact:
Re: Datagrid Check boxes
Regarding the error - Did you do anything else after changing from Form to Table? If I just switch to table in the object inspector and click the buttons I don't see any error message.
Did you customize one of the columns? If so then the the value passed to FillInData is NOT an array so pDataArray["checked"] would be empty. When working with tables the parameter passed to FillInData is the value of the column being populated. In this case you would just set the hilite of button "Check" of me to pData. Take a look at the lesson on customizing table columns:
http://lessons.runrev.com/spaces/lesson ... s-Columns-
You will find the code for selecting/deselecting the checkboxes in the lesson I provided. It will work the same for forms or tables. As long as you set the hilite state of the checkbox in FillInData based on a column value then the code will work.
Did you customize one of the columns? If so then the the value passed to FillInData is NOT an array so pDataArray["checked"] would be empty. When working with tables the parameter passed to FillInData is the value of the column being populated. In this case you would just set the hilite of button "Check" of me to pData. Take a look at the lesson on customizing table columns:
http://lessons.runrev.com/spaces/lesson ... s-Columns-
You will find the code for selecting/deselecting the checkboxes in the lesson I provided. It will work the same for forms or tables. As long as you set the hilite state of the checkbox in FillInData based on a column value then the code will work.
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder