How to apply Row and Column Templates to Datgagrid

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

bbhank
Posts: 116
Joined: Thu Mar 17, 2016 6:04 pm

How to apply Row and Column Templates to Datgagrid

Post by bbhank » Wed Mar 23, 2016 1:07 am

How does one apply Row Template to datagrid?
How does one get objects to appear in the grid when they are first drug onto it, as per the instructions? This is a missing step between dragging in the controls and setting up the behavior.
Please give succinct example(s) - script(s) that are understandable by the novice, beginner, newbie.

The more complex the piece, the more detailed, exact, and simple, starting instructions needed for new folks or beginners! This the case with the DataGrid.
:cry:
Last edited by bbhank on Thu Apr 14, 2016 3:23 pm, edited 3 times in total.

sritcp
Posts: 431
Joined: Tue Jun 05, 2012 5:38 pm
Location: Alexandria, Virginia

Re: How to apply Row and Column Templates to Datgagrid

Post by sritcp » Wed Mar 23, 2016 5:41 pm

http://lessons.livecode.com/m/datagrid/ ... w-template
(How do I Customize A Form's Row Template?)

http://lessons.livecode.com/m/datagrid/ ... -s-columns
(How Do I Customize A Table's Columns?)

Regards,
Sri

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: How to apply Row and Column Templates to Datgagrid

Post by MaxV » Fri Mar 25, 2016 1:04 pm

You can read also this: http://livecodeitalia.blogspot.it/2016/ ... agrid.html
the translate button is in the top left of the page
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

bbhank
Posts: 116
Joined: Thu Mar 17, 2016 6:04 pm

Re: How to apply Row and Column Templates to Datgagrid

Post by bbhank » Sat Mar 26, 2016 7:50 pm

Neither of the links suggested from LiveCode approach a solution to the question and problem as asked.

The problem is when in Form mode how to actually APPLY the template to the DataGrid. NONE of the instructions, tutorials, etc including the ones listed here, show one EXACTLY how to do this. I've tried the code in the lessons. They do not work and/or are not applicable to this application. The data here comes from a database and is populated by query. These queries work in other applications already on line but not in LiveCode. All searches point one back to these same crappy and unrelated excuses for tutorials and lessons on the LiveCode site.

In addition there should be a pull down that selects from available templates and applies the selected template to the DataGrid from the pull down. All the coding is troublesome, inefficient, time wasting, mistake prone, especially for beginners. This would make everybody's life easier.
Last edited by bbhank on Thu Apr 14, 2016 1:31 pm, edited 2 times in total.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7228
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: How to apply Row and Column Templates to Datgagrid

Post by jacque » Sun Mar 27, 2016 9:38 pm

bbhank wrote:The first "answer" is in Italian. I don't speak it.
You missed MaxV's comment just under the link that says "the translate button is in the top left of the page".
Neither of the links suggested from LiveCode approach a solution to the question and problem as asked.
Your question, as asked, can't be answered. It's the equivalent of "I need exact instructions on how to build a house." Any answer must assume that you know the basics of how to use all construction tools, understand the measurements you need, the design plan of the house, the materials you will use, etc. There is no single answer that fits each project.
The problem is when in Form mode how to actually APPLY the template to the DataGrid! NONE of the instructions, tutorials, etc including the ones listed here, show one EXACTLY how to do this.
The first LC tutorial does exactly that, but you need to understand the terminology it uses and the features it references, particularly "behaviors", which is a specific feature for sharing scripts among objects. It also may help to convert your data to a LC array, depending on what you're getting back from the database. The general idea is:

1. You edit the template to include the objects (fields and buttons, etc.) that should be displayed in each row.
2. You edit the behavior script of the datagrid to tell it how to fill those objects with content.

Everyone's objects and behavior scripts will be different. The datagrid provides the framework and does the complicated data display for you, but you need to link up the items from your database content to the objects in your template. There's no automatic way to do that, and no way for the template to "know" what you want displayed.
I've tried the code in the lessons. They do not work and are not applicable to this application. The data here comes from a database and is populated by query. These queries work in other applications already on line but not in LiveCode. All searches point one back to these same crappy and unrelated excuses for tutorials and lessons on the LiveCode site.
See above; of course the examples won't work because the scripts are designed to link to the example template, which isn't going to be like yours. It does teach the concepts; it is up to you to generalize those to your project. Where your data comes from (a database in your case) doesn't matter; it's all just data. It could be from a text file, or an http query, or anything else. The idea is to take that data and link it to the objects in the form.
In addition there should be a pull down that selects from available templates and applies the selected template to the DataGrid from the pull down. All the coding is troublesome, inefficient, time wasting, mistake prone, especially for beginners. This would make everybody's life easier.
Again, there can be no generalized templates. Each template is designed by you to display the things specific to your data. This is no different than the design and layout you place on every card.

The frustration you are feeling right now is quite normal when learning a new environment and it will pass. You do need a certain amount of info before the paradigm falls into place and you get that "eureka" moment. Until that happens you'll probably feel you've hit a wall (or like you want to) -- but I encourage you to continue. Usually after about six weeks or so of wanting to sledgehammer your computer, a sudden light appears and everything becomes clear. I've seen it happen to dozens and dozens of now-proficient LiveCoders.

Tell you what -- if you post the exact content of one row of data, we can probably at least help you fill out the behavior script, which is the linking part you're asking about. You'll also need to tell us what objects you have placed in the form. If you include a snapshot of your template form, even better. We can help if we know what you're trying to work with.

Don't give up yet.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

bbhank
Posts: 116
Joined: Thu Mar 17, 2016 6:04 pm

Re: How to apply Row and Column Templates to Datgagrid

Post by bbhank » Mon Mar 28, 2016 5:03 pm

Super reply.
Sure nuff missed max tho.
There have been multiple epiphanies though.
I found this one was a little strange tho. Once I found the way the data grid is able to display, the default area turned out to be really small. That's how I missed it. I can laugh now but at first :evil: . Whew! Got it. What I was looking for was there all the time but not readily visible.
I like the one about the house. I'm lucky enough to be working in a niche where all the houses are new and unique. That's both good and bad. Since this is the first, there's nothing to look to that's ahead of it. The good is that it is useful and this creating this app is a stage of growth.
Yes, the terminology is daunting in some places. Like learning Portuguese. Gotta be there.

My Datagrid wish list tho is to have the layout be totally drag and drop, then be able to tap the objects for what you want them to do. Still use the Behavior window and object windows code windows to tweak what you can't by dragging and dropping, and to do custom control, like working with databases or multimedia. Looks like the framework to do that is already there. :D
Thanks all.

bbhank
Posts: 116
Joined: Thu Mar 17, 2016 6:04 pm

Re: How to apply Row and Column Templates to Datgagrid

Post by bbhank » Thu Mar 31, 2016 3:28 pm

Deja vu.
Since I first found LiveCode on the web, no more than a couple of months ago, there was something strangely familiar about it. When I found out what that was, a lot about using LiveCode became easier, and even possible for me:
I was a Mac guy when they were young (Actually starting on the Apple IIc) and used HyperCard to produce what are called "apps" today.
:) :D

bbhank
Posts: 116
Joined: Thu Mar 17, 2016 6:04 pm

Re: How to apply Row and Column Templates to Datgagrid

Post by bbhank » Mon Apr 11, 2016 4:10 pm

I managed to get this one to work but can't seem to start a new one from scratch. I had this same problem at first. The big stumbling block here in initially setting up the datagrid is where and what is the field that actually controls what you see. In the Row Template there are multiple fields when you start. My question is which of these put the items drug from the tool palate onto the grid actually cause the item drug to show up. I've looked all over for a good startup tutorial and keep being sent back to the same LiveCode tutorial which doesn't explain starting well at all. Tried BYU's tutorials also but you have to be a student to access more.

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: How to apply Row and Column Templates to Datgagrid

Post by MaxV » Wed Apr 13, 2016 9:32 am

Translated from http://livecodeitalia.blogspot.it/2016/ ... agrid.html
...when you creates a datagrid, livecode creates a substack called "Data Grid Templates..." and a number. This substack contains 2 cards:
  • one with instructions, called DatagridTempaleInstrucion
  • one with all objects of our datagrid
Image
Let's add 3 columns and click on the plus button of the property inspector for columns 2 and 3.
Now we have two groups: col2 and col3. These groups must be modified to personalize our datagrid. In these groups let's remove the the text field and put a button.
Image
Close and save the substack.
Now we must modify the script behaviours. If you look in the application browser, we have two buttons called col 2 behavior and col 3 behavior. Edit the scripts of these buttons. I suggest you to exchange the word field with the word button in the messages: LayoutControl, FillInData, ResetData.
End of the story.
Save, close and reopen all.
Now with

Code: Select all

send "addLine 1" to group 1
you add lines to the datagrid.
Image
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

bbhank
Posts: 116
Joined: Thu Mar 17, 2016 6:04 pm

Re: How to apply Row and Column Templates to Datgagrid

Post by bbhank » Thu Apr 14, 2016 1:10 am

What version of LiveCode are you using?
I'm using version 8.

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: How to apply Row and Column Templates to Datgagrid

Post by MaxV » Thu Apr 14, 2016 11:27 am

Version 8 is highly experimental, please use a 7.x version. :D
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

bbhank
Posts: 116
Joined: Thu Mar 17, 2016 6:04 pm

Re: How to apply Row and Column Templates to Datgagrid

Post by bbhank » Thu Apr 14, 2016 12:09 pm

I have version 7 also. Here is my first screen when I drag a datagrid into the project window.
DataGrid 1.png
How are items placed into/onto the datagrid so that they show up and are usable in the project, is the question. I've been through lots of tutorials and so forth without finding usable answers.

bbhank
Posts: 116
Joined: Thu Mar 17, 2016 6:04 pm

Re: How to apply Row and Column Templates to Datgagrid

Post by bbhank » Thu Apr 14, 2016 12:25 pm

(How do I Customize A Form's Row Template?)

http://lessons.livecode.com/m/datagrid/ ... -s-columns
(How Do I Customize A Table's Columns?)

Regards,
Sri[/quote]

This is after the datagrid and template have been created. I'm asking how to get the objects to appear initially.
The grid is a form and not a table.
This instruction points to a part of the datagrid and doesn't explain what to do. There are several fields there and which one makes the objects actually appear in the datagrid and that is the question.
Notice here that the instruction points to a place in the template without showing exactly how it is used. It skips off into behavior without finishing telling one how exactly how to get the objects to show up on the grid in the first place.
media_1238098894025_display.png
This is where the instructions leaves one hanging. At no point does it explain how to get objects to actually appear in the datagrid in any format the layman can understand. I'm trying to find out what are the Exact steps - step by step. :cry: :x :? I realize that the datagrid is a complex piece of equipment but that doesn't give any excuse for not having good starting instruction.

bbhank
Posts: 116
Joined: Thu Mar 17, 2016 6:04 pm

Re: How to apply Row and Column Templates to Datgagrid

Post by bbhank » Thu Apr 14, 2016 1:35 pm

"You missed MaxV's comment just under the link that says "the translate button is in the top left of the page"."

Thank you Jacque. I did miss that. The way he's done that is impressive.

sritcp
Posts: 431
Joined: Tue Jun 05, 2012 5:38 pm
Location: Alexandria, Virginia

Re: How to apply Row and Column Templates to Datgagrid

Post by sritcp » Thu Apr 14, 2016 2:28 pm

Hi bbhank:

1. Drag a datagrid control onto a card; now you have an empty datagrid.

2. To create a datagrid Form, first you need to lay out how you want the row to look. For this purpose, you click on the "Row Template" in the properties inspector. This takes to to the Row Template Editor, where you assemble your row by dragging in controls. You may want, e.g., a field, a picture, a menu, and a check box. Once you lay this out, this will be the template for every row in your form.

3. Your database will provide data for what text, picture, or menu choice should appear in each row. This is done by editing the Row Behavior. Click "Row Behavior" button in the property inspector. This will take you to the FillinData handler. It takes as its argument one row of your database, in the form of an array. Edit this handler to assign data for each row. Edit the LayoutControl handler to adjust the layout of the row components dynamically.

The next time your datagrid is refreshed (as when you open a card), the data should appear in your datagrid.

Does this answer your question?

Regards,
Sri

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”