Page 1 of 2

Mapping data to database from a button click, button in grid row

Posted: Wed Feb 12, 2014 12:55 pm
by Vaishali Patel

I have a grid that is populated dynamically from a database table, each row has a button.

When that button is clicked I want that row information to be inserted into another table.
I have done the mapping and the JS etc but the data is not being inserted into the database.

PLease help

My screenshots are attached

Image Image Image Image Image Image


Mapping data to database from a button click, button in grid row

Posted: Wed Feb 12, 2014 2:43 pm
by Maryna Brodina

Hello! Please check console. What Create service returns? What do you send in OrderId (which is pointer in DB). As we can see from the screenshot you have just one _id on the screen - it's ProductId most likely. In OrderId you add txtQty, could you clarify what is txtQty? What is stored there? If you add it to pointer field, there should be valid existing _id.


Mapping data to database from a button click, button in grid row

Posted: Wed Feb 12, 2014 2:52 pm
by Vaishali Patel

In OrderId is the Id of the order which is stored in local variable and also displayed on screen (see screenshot)

txtQty is the textbox next to the Add button (but with ...), so whatever the user the types in there. This is not a pointer field in the collection, just a number

Image


Mapping data to database from a button click, button in grid row

Posted: Wed Feb 12, 2014 4:38 pm
by Kateryna Grynko

Hi Vaishali,

Please map Session token.


Mapping data to database from a button click, button in grid row

Posted: Wed Feb 12, 2014 4:41 pm
by Vaishali Patel

Where do I get session token from?

I have not had to map this before for the other mappings I have done


Mapping data to database from a button click, button in grid row

Posted: Wed Feb 12, 2014 5:10 pm
by Kateryna Grynko

Vaishali,

You should first login in your app using Login service: http://docs.appery.io/documentation/b...


Mapping data to database from a button click, button in grid row

Posted: Wed Feb 12, 2014 5:18 pm
by Vaishali Patel

Firstly I do not need a login for the app yet,so I have no need to use the Login Service,

I have defined 4 collections in my database
Customer
Order
Products
OrderItem

In my app, the second screen allows user to enter information, that information is inserted into Customers Collection, this works on a button click and is working great. The CustomerId is put into a local variable

Screen three - when Load is clicked, the data from the products collection is used to populate the grid, this works great.

On Load click an Order is also created and the customerId from the local variable also gets inserted, this works great,

So why do I need a session token to create an OrderItem??


Mapping data to database from a button click, button in grid row

Posted: Wed Feb 12, 2014 5:25 pm
by Vaishali Patel

Could this be a bug!?

That buttons within a grid are not triggering an event?


Mapping data to database from a button click, button in grid row

Posted: Wed Feb 12, 2014 6:16 pm
by Kateryna Grynko

Vaishali,

This event must be executed. Are there any console errors (F12)?


Mapping data to database from a button click, button in grid row

Posted: Wed Feb 12, 2014 7:03 pm
by Vaishali Patel

No Errors that I can see in the console.

Could you please explain why this event must be executed?