Button in Data Grid
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Button in Data Grid
Hi,
I have not been successful in adding a push button to my data grid. If anyone can point me to an example I would appreciate it.
Thanks.
I have not been successful in adding a push button to my data grid. If anyone can point me to an example I would appreciate it.
Thanks.
Bruce Peaslee
Windows 7 Home Premium (Service Pack 1)
ACPI x-64 based PC 9GB RAM
Windows 7 Home Premium (Service Pack 1)
ACPI x-64 based PC 9GB RAM
Re: Button in Data Grid
Hi peaslee,
what did you try so far?
What should that button do?
In any case you need a datagrid of type "Form"!
Best
Klaus
what did you try so far?
What should that button do?
In any case you need a datagrid of type "Form"!
Best
Klaus
Re: Button in Data Grid
I want a button with the little pencil icon so the user, by clicking it, will open a stack to edit the record.
The closest I came to success was following the "How to I work with Checkboxes in a Data Grid Example". I can get that to run properly, but I can't seem to get a push button in the Row Template.
The closest I came to success was following the "How to I work with Checkboxes in a Data Grid Example". I can get that to run properly, but I can't seem to get a push button in the Row Template.
Bruce Peaslee
Windows 7 Home Premium (Service Pack 1)
ACPI x-64 based PC 9GB RAM
Windows 7 Home Premium (Service Pack 1)
ACPI x-64 based PC 9GB RAM
-
- Livecode Opensource Backer
- Posts: 430
- Joined: Sun Feb 13, 2011 8:43 pm
- Location: Seattle, USA
Re: Button in Data Grid
This tutorial shows how to put a checkBox in a DataGrid.
I think the process is the same for buttons.
Data Grid Helper Plugin - How Do I Create a Checkbox in a Column?
Download the trial version here: DataGrid Helper Plugin.
Otherwise coding gets very involved-- modifying DataGrid Templates and Behavior Scripts.
I think the process is the same for buttons.
Data Grid Helper Plugin - How Do I Create a Checkbox in a Column?
Download the trial version here: DataGrid Helper Plugin.
Otherwise coding gets very involved-- modifying DataGrid Templates and Behavior Scripts.
Re: Button in Data Grid
I've had some success - the button and sample data appear. However, I can't figure out how to get column names, nor can I get the button to do something simple like return the data in its row.
Bruce Peaslee
Windows 7 Home Premium (Service Pack 1)
ACPI x-64 based PC 9GB RAM
Windows 7 Home Premium (Service Pack 1)
ACPI x-64 based PC 9GB RAM
Re: Button in Data Grid
Hi peaslee,
again, what did you script so far for the button?
Best
Klaus
again, what did you script so far for the button?
Best
Klaus
Re: Button in Data Grid
Here's what I scripted as a test. The row has trhe button and two label fields. The label fields do show data.
This causes an error and displays code that I assume is part of the underlying system.
Code: Select all
on mouseUp
local tLastName
local tFirstName
put the text of field "lblLastName" of me into tLastName
put the text of field "lblFirstName" of me into tFirstName
answer info tLastName & ", " & tFirstName
end mouseUp
Bruce Peaslee
Windows 7 Home Premium (Service Pack 1)
ACPI x-64 based PC 9GB RAM
Windows 7 Home Premium (Service Pack 1)
ACPI x-64 based PC 9GB RAM
Re: Button in Data Grid
'me' in this context is probably not the row of the data grid.
I suspect you'll need to get the index (or line) the button is in, and then use dgDataOfIndex (Line) to retrieve the data array.
I suspect you'll need to get the index (or line) the button is in, and then use dgDataOfIndex (Line) to retrieve the data array.
-
- VIP Livecode Opensource Backer
- Posts: 163
- Joined: Tue Jan 26, 2010 10:15 pm
- Contact:
Re: Button in Data Grid
Dear Klaus,Klaus wrote:Hi peaslee,
In any case you need a datagrid of type "Form"!
Buttons, images, fields or what ever you want, can be used indifferently in datagrid templates linked to a form or a column.
Here is an example:
The properties window is a datagrid table with two columns. The "Value" column contains different objects such as menus, rectangles, buttons, etc...
peaslee wrote:Here's what I scripted as a test. The row has trhe button and two label fields. The label fields do show data.
This causes an error and displays code that I assume is part of the underlying system.Code: Select all
on mouseUp local tLastName local tFirstName put the text of field "lblLastName" of me into tLastName put the text of field "lblFirstName" of me into tFirstName answer info tLastName & ", " & tFirstName end mouseUp
Dear Bruce,peaslee wrote:I want a button with the little pencil icon so the user, by clicking it, will open a stack to edit the record.
The closest I came to success was following the "How to I work with Checkboxes in a Data Grid Example". I can get that to run properly, but I can't seem to get a push button in the Row Template.
Where did you added the buttons scripts? Directly in the buttons or in the column behavior?
Best regards,
TheSlug
http://www.aslugontheroad.com - Tutorials, demo stacks and plugins for LiveCode
Data Grid Helper - An intuitive interface for building LiveCode's Data Grids
Excel Library- Extends the LiveCode language for controlling MS Excel
http://www.aslugontheroad.com - Tutorials, demo stacks and plugins for LiveCode
Data Grid Helper - An intuitive interface for building LiveCode's Data Grids
Excel Library- Extends the LiveCode language for controlling MS Excel
Re: Button in Data Grid
Slug,
I put the button's script in the column behavior.
Bruce
I put the button's script in the column behavior.
Bruce
Bruce Peaslee
Windows 7 Home Premium (Service Pack 1)
ACPI x-64 based PC 9GB RAM
Windows 7 Home Premium (Service Pack 1)
ACPI x-64 based PC 9GB RAM
-
- VIP Livecode Opensource Backer
- Posts: 163
- Joined: Tue Jan 26, 2010 10:15 pm
- Contact:
Re: Button in Data Grid
How many columns do you have ?peaslee wrote:Slug,
I put the button's script in the column behavior.
Bruce
- Only one with 2 fields (first and last name) and a button
- Three columns (a first name column, a last name column and a column with a button)
TheSlug
http://www.aslugontheroad.com - Tutorials, demo stacks and plugins for LiveCode
Data Grid Helper - An intuitive interface for building LiveCode's Data Grids
Excel Library- Extends the LiveCode language for controlling MS Excel
http://www.aslugontheroad.com - Tutorials, demo stacks and plugins for LiveCode
Data Grid Helper - An intuitive interface for building LiveCode's Data Grids
Excel Library- Extends the LiveCode language for controlling MS Excel
Re: Button in Data Grid
Three columns: a button and two fields.Zryip TheSlug wrote:How many columns do you have ?peaslee wrote:Slug,
I put the button's script in the column behavior.
Bruce
- Only one with 2 fields (first and last name) and a button
- Three columns (a first name column, a last name column and a column with a button)
Bruce Peaslee
Windows 7 Home Premium (Service Pack 1)
ACPI x-64 based PC 9GB RAM
Windows 7 Home Premium (Service Pack 1)
ACPI x-64 based PC 9GB RAM
-
- VIP Livecode Opensource Backer
- Posts: 163
- Joined: Tue Jan 26, 2010 10:15 pm
- Contact:
Re: Button in Data Grid
Ok. In this case, as point out by dglass, "me" is not the row of the datagrid. For datagrid table, consider "me" as the cell in the row. Inside the cell which contains the button, you will not be able to get a value in a field located in another cell.peaslee wrote: Three columns: a button and two fields.
Assuming your two text columns are named:
- Last Name
- First Name
A possible solution is to use the getDataOfIndex function of the datagrid library. This function will help you to get a value inside a column in the datagrid data.
You will learn more informations about this function by reading this lesson:
http://lessons.runrev.com/spaces/lesson ... or-Column-
Add this script in the column behavior of the column button:
Code: Select all
on mouseUp pTheButton
if (pTheButton is 1) then
if (the short name of the target is "My Button") then
put the dgIndex of me into tTheIndex
answer info getDataOfIndex(tTheIndex, "Last Name") && getDataOfIndex(tTheIndex, "First Name")
end if
end if
end mouseUp
Best,
TheSlug
http://www.aslugontheroad.com - Tutorials, demo stacks and plugins for LiveCode
Data Grid Helper - An intuitive interface for building LiveCode's Data Grids
Excel Library- Extends the LiveCode language for controlling MS Excel
http://www.aslugontheroad.com - Tutorials, demo stacks and plugins for LiveCode
Data Grid Helper - An intuitive interface for building LiveCode's Data Grids
Excel Library- Extends the LiveCode language for controlling MS Excel