Basket help
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Basket help
im trying to make a app that at the end of the stack i.e the checkout/basket stack i can see a table with all the product the person wants by clicking a button. however i can do this but only on the same stack the table is on? is it possible to click a button from another stack to the checkout/basket stack and it puts data into the table?
would really appreciate help
would really appreciate help
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: Basket help
Hi AzTheBest
welcome to this forum.
I think you can do that with a stack or a substack. I don't know what is the best way for your project.
Best regards
Jean-Marc
welcome to this forum.
I think you can do that with a stack or a substack. I don't know what is the best way for your project.
Best regards
Jean-Marc
https://alternatic.ch
Re: Basket help
thanks
and im trying to make my app like domino app but finding it difficult to make the checkout page
also that when i click the button "add" it automatcitally enters all the details of the product in the checkout page stack but i keep getting erros
and im trying to make my app like domino app but finding it difficult to make the checkout page
also that when i click the button "add" it automatcitally enters all the details of the product in the checkout page stack but i keep getting erros
-
- VIP Livecode Opensource Backer
- Posts: 9785
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Basket help
Hi.
You can do what you ask easily. But you need to get more familiar with LC while you are working. Make a few stacks. In each one, place a field or two, and a button that goes to one or the other of those stacks, so you can navigate freely among them. Now do something like "put random(999) into fld 1 of stack "oneOfTheOtherStacks"
See?
Craig Newman
You can do what you ask easily. But you need to get more familiar with LC while you are working. Make a few stacks. In each one, place a field or two, and a button that goes to one or the other of those stacks, so you can navigate freely among them. Now do something like "put random(999) into fld 1 of stack "oneOfTheOtherStacks"
See?
Craig Newman
Re: Basket help
still really confused
this is what it looks like in the picture
when i click the drink button it deletes everything in the first row for the chicken button
when i click the chicken button it deletes the first rown for the drink
i want it to add underneath with no set number so when i press the button it goes to the next row
for example i click the chicken button it makes a duplicate row but underneath the first one
(sorry for stupid button name just thought might help easier to explain)
this is what it looks like in the picture
when i click the drink button it deletes everything in the first row for the chicken button
when i click the chicken button it deletes the first rown for the drink
i want it to add underneath with no set number so when i press the button it goes to the next row
for example i click the chicken button it makes a duplicate row but underneath the first one
(sorry for stupid button name just thought might help easier to explain)
Re: Basket help
You should probably look at the lessons here: http://lessons.livecode.com/m/datagrid to get a better grasp of the datagrid.
From your code, it looks like you're building an array, and specifying a key of 1 (myarray[1])
Then you set the dgdata to myarray. This overwrites the current contents of the datagrid, with the contents of the array, and since you only have the one key, you end up with only one row in the datagrid.
I gave you the link above which is for a bunch of lessons about the datagrid, the specific one you should look at is here: http://lessons.livecode.com/m/datagrid/ ... -data-grid
(edit)
Heres a quick example..
Notice, there is no numeric key for this, instead you find out how many lines are already in the dg, add 1, and use that to tell the dg where to put the new data.
Then, since your code (in the button) is outside the message path for the datagrid, you use dispatch to send the command along with the required data to the datagrid which then will insert the new record.
Edit 2: DOH, the line above that gets the number of records should be put, not get
From your code, it looks like you're building an array, and specifying a key of 1 (myarray[1])
Then you set the dgdata to myarray. This overwrites the current contents of the datagrid, with the contents of the array, and since you only have the one key, you end up with only one row in the datagrid.
I gave you the link above which is for a bunch of lessons about the datagrid, the specific one you should look at is here: http://lessons.livecode.com/m/datagrid/ ... -data-grid
(edit)
Heres a quick example..
Code: Select all
put "Chicken Steak" into theDataA["Main Menu"]
put "$5" into theDataA["cost"]
get the dgNumberOfRecords of grp "YourDataGrid" + 1 into theLineNo
dispatch "AddData" to group "yourDataGrid" with theDataA, theLineNo
Then, since your code (in the button) is outside the message path for the datagrid, you use dispatch to send the command along with the required data to the datagrid which then will insert the new record.
Edit 2: DOH, the line above that gets the number of records should be put, not get
Code: Select all
put the dgNumberOfRecords of grp "YourDataGrid" + 1 into theLineNo
-
- VIP Livecode Opensource Backer
- Posts: 9785
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Basket help
I use dataGrids, and am fond of saying I do not understand them.
I am amazed at how attractive they are to new users. So many start right in with them embedded in their projects, oftentimes the central control.
I understand why, but also see that these users quickly get in over their heads. The main reason is that DG's have their own syntax and structure, and it is possible to ignore the basics of LC's syntax and structure while quietly struggling in that arena.
They should come with a warning.
Craig
I am amazed at how attractive they are to new users. So many start right in with them embedded in their projects, oftentimes the central control.
I understand why, but also see that these users quickly get in over their heads. The main reason is that DG's have their own syntax and structure, and it is possible to ignore the basics of LC's syntax and structure while quietly struggling in that arena.
They should come with a warning.
Craig
Re: Basket help
Agreed! Nothing like jumping off into the deep end. Thankfully there are lots of lessons and tips and tricks re: the datagrid, but even so. If I can accomplish a task ANY other way, I do. (For most of my uses its way to complex to mess with)
dunbarx wrote:I use dataGrids, and am fond of saying I do not understand them.
I am amazed at how attractive they are to new users. So many start right in with them embedded in their projects, oftentimes the central control.
I understand why, but also see that these users quickly get in over their heads. The main reason is that DG's have their own syntax and structure, and it is possible to ignore the basics of LC's syntax and structure while quietly struggling in that arena.
They should come with a warning.
Craig
Re: Basket help
hey thank you so much and im one step closer to finishing my app and these are the results
however i want the button to be on a different stack page or card not on the same stack or card page as the table
i copied the button and the code to a different stack however i keep getting error? is it not possible to send data like this in live code?
however i want the button to be on a different stack page or card not on the same stack or card page as the table
i copied the button and the code to a different stack however i keep getting error? is it not possible to send data like this in live code?
Re: Basket help
When you "dispatch" you have to make sure livecode knows where to find the control you're dispatching to.
If you only provide the control name, it looks at stack that the dispatch is being sent from. So if you have a button in one stack, and you want to dispatch to a control in another stack you need to give it a full "path" to find the control.
so if you have stack "firstStack" with your button to dispatch
and stack "stackWithDatagrid" you would need to be specific with your dispatch.
Something like
dispatch "addData" to group "datagrid" of card "cardWithDatagrid" of stack "stackWithDatagrid" with theDataA,theLineNo
You might look at some of the stuff on http://lessons.livecode.com just because there are a bunch of basic concents that will help you get the most out of your coding. (like understanding the message path!)
Good luck. Oh, and you said you keep getting an error, i'm just guessing as to what the problem was, if my suggestion doesn't help, let us know what the error is and i'm sure someone can help.
If you only provide the control name, it looks at stack that the dispatch is being sent from. So if you have a button in one stack, and you want to dispatch to a control in another stack you need to give it a full "path" to find the control.
so if you have stack "firstStack" with your button to dispatch
and stack "stackWithDatagrid" you would need to be specific with your dispatch.
Something like
dispatch "addData" to group "datagrid" of card "cardWithDatagrid" of stack "stackWithDatagrid" with theDataA,theLineNo
You might look at some of the stuff on http://lessons.livecode.com just because there are a bunch of basic concents that will help you get the most out of your coding. (like understanding the message path!)
Good luck. Oh, and you said you keep getting an error, i'm just guessing as to what the problem was, if my suggestion doesn't help, let us know what the error is and i'm sure someone can help.
Re: Basket help
omg thank you so much i love the support here im so close finishing this project now
Re: Basket help
i want a dropdown menu in the quantity column and it would contain numbers 1-10
As then i would want the the total column table to multiply the cost of the product depending on the quantity numerical number
(sorry for being a pain as ive tried the website and finding it difficult to understand them )
As then i would want the the total column table to multiply the cost of the product depending on the quantity numerical number
(sorry for being a pain as ive tried the website and finding it difficult to understand them )
Re: Basket help
First look here: http://lessons.livecode.com/m/datagrid/ ... -s-columns
You'll want to create a custom column template for your quantity column.
You'll also want to create a custom column template for your total column for that item.
You'll want to script for the behavior of both columns. For the quantity column, you'll need to be able to change the datagrid value for that row based on the quantity you select. The linked lesson will hopefully get you on the right path for that.
For the total column, you will need to script the behavior to grab the row data, and use the quantity and price to populate the item total. I'm afraid this is at the point where just whipping out code off the top of my head isn't very realistic. (If you don't mind sharing, post the stack with your datagrid (zipped or on dropbox) and I'll look at it and try to write up a step by step tutorial. (did I mention though, the more lessons you go through, the more of the "big picture" you will get and the easier it will be to get a habndle on the more complicated stuff?) Lessons are your friend!
You'll want to create a custom column template for your quantity column.
You'll also want to create a custom column template for your total column for that item.
You'll want to script for the behavior of both columns. For the quantity column, you'll need to be able to change the datagrid value for that row based on the quantity you select. The linked lesson will hopefully get you on the right path for that.
For the total column, you will need to script the behavior to grab the row data, and use the quantity and price to populate the item total. I'm afraid this is at the point where just whipping out code off the top of my head isn't very realistic. (If you don't mind sharing, post the stack with your datagrid (zipped or on dropbox) and I'll look at it and try to write up a step by step tutorial. (did I mention though, the more lessons you go through, the more of the "big picture" you will get and the easier it will be to get a habndle on the more complicated stuff?) Lessons are your friend!
Re: Basket help
i tried dude and its making no sense to me can u please help me out ive send a attachemnt of the table
- Attachments
-
- coding help.rar
- (4.13 KiB) Downloaded 209 times
Re: Basket help
It appears that you have run into one of the reasons I avoid the datagrid if at all possible. In technical terms, then datagrid in your stack is "Broken."
I would suggest making a backup of your stack just in case, then delete the broken datagrid. I would even go so far as to answer "YES" when it asks about removing the template data too.
Then i would start rebuilding the datagrid. Saving OFTEN with different stack names (file, save as) so that you have versioning. This way if it "breaks" again you know what the most recent thing you did was, and maybe we can track down whats breaking it. And, you have a version that still works so you can try again without having to do a full rebuild.
I'm going to go through duplicating your dg and see if I can either a) break it, or b) get it to work as you need it. (I have a theory as to why it broke. I'll find out as I go along)
I would suggest making a backup of your stack just in case, then delete the broken datagrid. I would even go so far as to answer "YES" when it asks about removing the template data too.
Then i would start rebuilding the datagrid. Saving OFTEN with different stack names (file, save as) so that you have versioning. This way if it "breaks" again you know what the most recent thing you did was, and maybe we can track down whats breaking it. And, you have a version that still works so you can try again without having to do a full rebuild.
I'm going to go through duplicating your dg and see if I can either a) break it, or b) get it to work as you need it. (I have a theory as to why it broke. I'll find out as I go along)