DataGrid Table; entering more rows of data

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
CAsba
Posts: 389
Joined: Fri Sep 30, 2022 12:11 pm

DataGrid Table; entering more rows of data

Post by CAsba » Tue Feb 21, 2023 12:44 pm

Hi,
I just set up a datagrid table for customers' data, name, address, etc. There is a button that puts the data inputted by the user (new customer) into the Dg. I have one line of data - that is, one customer in the table. When I try to enter a second customer's details it just overwrites the first one. The lesson lost me inasmuch as it goes into editing the row template, but I don't need to edit to enhance the presentation as the table will never be seen, it will just issue the data to invoices, etc., according to a user-selected customer code. Can anyone advise me in simple terms how to enter a second, and successive rows into the dg ?

Klaus
Posts: 13872
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: DataGrid Table; entering more rows of data

Post by Klaus » Tue Feb 21, 2023 12:51 pm

Hi CAsba,
CAsba wrote:
Tue Feb 21, 2023 12:44 pm
There is a button that puts the data inputted by the user (new customer) into the Dg. I have one line of data - that is, one customer in the table. When I try to enter a second customer's details it just overwrites the first one.
the big question is, what did you script in that namely button?
Tell us and we will be able to point you to the problem.

Best

Klaus

CAsba
Posts: 389
Joined: Fri Sep 30, 2022 12:11 pm

Re: DataGrid Table; entering more rows of data

Post by CAsba » Tue Feb 21, 2023 1:06 pm

Hi Klaus, the code is

Code: Select all

put fld "newcode" of cd "enter new customer" & tab & fld "bizname" of cd "enter new customer" & tab & fld "line2" of cd "enter new customer" & tab & fld "line3" of cd "enter new customer" & tab & fld "line4" of cd "enter new customer" & tab & fld "line5" of cd "enter new customer" & tab & fld "line6" of cd "enter new customer" & tab & fld "line7" of cd "enter new customer" & tab & fld "line8" of cd "enter new customer" & tab & fld "line9" of cd "enter new customer" & tab & fld "line10" of cd "enter new customer" & tab & fld "line11" of cd "enter new customer" into theText
   put false into firstLineContainsColumnNames
   set the dgText [ firstLineContainsColumnNames ] of group "DataGrid 1" to theText

Klaus
Posts: 13872
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: DataGrid Table; entering more rows of data

Post by Klaus » Tue Feb 21, 2023 1:12 pm

AHA! :D
Well, setting "the dgtext of grp xyz to zxy" will overwrite the complete content of the datagrid and not only the last line!

You just want to:

Code: Select all

...
put fld "newcode" of cd "enter new customer" & tab & ... into theText
dispatch "addline" to grp "DataGrid 1" with theText
...
Best

Klaus

CAsba
Posts: 389
Joined: Fri Sep 30, 2022 12:11 pm

Re: DataGrid Table; entering more rows of data

Post by CAsba » Tue Feb 21, 2023 1:52 pm

Many thanks Klaus, worked a treat.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”