DataGrid Manual Updating

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

Post Reply
ckingram2006
Posts: 2
Joined: Thu Jun 05, 2014 9:53 pm

DataGrid Manual Updating

Post by ckingram2006 » Thu Jun 05, 2014 10:08 pm

Hello Everyone,

I am new to the forum (and Livecode for that matter) and have been enjoying the last 3 weeks learning this language as my first serious attempt to learn programming. I have tackled many of the basics and plan on focusing on Programming as a new tool in my IT toolbox with LC being the tool of choice. My question today is about manually adding rows/records to the datagrid. I am sure this is probably simple and I did attempt to search the forum prior to posting a question but did not find what I was looking for. Here is my situation:

I want to be able to use a standard button and have this button pass variable data to the datagrid on mouse up. An example would be if I had a button named Sandwich the Sandwich button would have a variable named varDescription and another variable named varPrice. I would like to set a description and price for this Sandwich button. When the button is clicked I would like for the varDescription value and the varPrice value to be passed to the datagrid which would have 2 columns (description and Price). Any help in understanding how to write this effectively would be appreciated. Thanks in advance for any advice and I am very excited to be joining this amazing forum.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10335
Joined: Wed May 06, 2009 2:28 pm

Re: DataGrid Manual Updating

Post by dunbarx » Fri Jun 06, 2014 4:12 am

Hi.

Even the experienced in this forum approach dataGrids with caution. Not that they have problems, rather that they are complex and powerful, and require care. My point is that as a very new user, you need to make sure you have the basics of LC cold before you try to manage DG's. Message path, properties, commands and functions, etc. Can you make an address book or a calculator?

But if you still intend to jump in, you should certainly make sure you have at least skimmed through the manual.

Make a new DG. Name it. Try this in a button script:

Code: Select all

on mouseUp
put "AA" & tab & "BB" & tab & "CC" & return & "DD"  & tab & "EE" & tab & "FF" & return & "GG" & tab & "HH" & tab & "JJ" into temp
set the dgText of group 1 to temp --your name here
end mouseUp
This is about the simplest way to get data into a DG. The "DGText" is a property of the group (DG's are nothing if not groups) and deals with clear data. You can "set" and "get" that proerty and massage the data, as I say, in the clear. Have you started with arrays yet? Check out the "DGData", but do that later.

So if you place the contents of the DG into a variable, and set the itemDelimiter to tab, and then change one or another item, and then...

Are you OK with this sort of rant?

Play with some of the other vocabulary in the DG manual. Good luck. Write back often. You. have set yourself an ambitious program

Craig Newman

ckingram2006
Posts: 2
Joined: Thu Jun 05, 2014 9:53 pm

Re: DataGrid Manual Updating

Post by ckingram2006 » Fri Jun 06, 2014 7:37 pm

Thanks Craig,

Your "rant" was received very well. My path to becoming a successful LiveCode programmer although new is a commitment that I am taking very seriously so any advice that I receive is appreciated. As far as the basics, I am able to create basic calculator programs, word games, etc. Maybe my ambition of working with datagrids etc is a little premature for my level of understanding and will look at other methods for progressing. The main issue that I am running into is finding training material that goes beyond the basics. If you have any recommendations of any training material/books/videos that go beyond mobile development and games that would be really helpful. Thanks once again and I value your feedback.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10335
Joined: Wed May 06, 2009 2:28 pm

Re: DataGrid Manual Updating

Post by dunbarx » Fri Jun 06, 2014 7:55 pm

Hi.

If you can make the sort of gadgetry you mentioned (or was it me?) then I take part of what I said back. You have progressed very nicely indeed.

My caveat was based on this, that you would not know what a property even was, for example, much less be able to deal with the very DG-centric ones you will come across when you are working in that arena. Datagrids are composed entirely of LC objects, groups and behaviors, and as such are completely accessible to the user. They also were written by, essentially, one person, and live to a great extent in their own world. You almost need a new lexicon, apart from LC itself, to deal with them.

Other than that. The manual and the lessons are where I would start. You need to practice, and likely take notes on what terms work well for you. The lessons are at:

http://lessons.runrev.com/m/datagrid

Good luck

Craig

Post Reply