Dynamic linking gets cleared when inserting new records - x++

I have one form in AX 2012 from which i am calling another child form which shows records that are related to the selected record in Parent form(Dynamic linking).
Now, when I am trying to create a new record in a child form, the dynamic linking between this form and its parent form gets cleared and child form starts showing all data according to its datasource and not any filtered records which I don't want.
I want to know that, how to get stick with that dynamic linking while creating new Record in a child form.

Check that your grids really belongs to the correct datasources. If not, strange things happen.

Related

Datatable for a child record asp.net mvc

I have a cshtml view to perform crud operations on a client record. In the same view i want a data table to perform crud operations on children of each client , so one client can have multiple children. I want to add edit those child records however only when the entire client record is saved then the child record should be updated or created , deleted etc. Can i know if jquery datatable is the best for this , and how will i save child in memory and perform save all at once...thanks
Used javascript arrays, and hidden variables to make sure that added/edited data is not lost when posted back to controller .
You can load load the datatable child using Ajax (on click event of the client table). Then read all rows from the datatable child to get the data that you need.

Creating multiple items with a single creation workflow

I'm trying to create multiple items (associated classes) from the parent class to the very child one (4 level deep) in a single workflow. I'd like to be able to create the parent item, then click on "next" to be able to create one/many children, then click on "next" to create the children of the children, and so on... Finally, in the last screen, i'd like to be able to save all the items by clicking on save. If something is missing in the child item, the parent class cannot be created as well.
Do we have any ideas of how i can manage to do that?
Many thanks :)
You can use accepts_nested_attributes_for in the parent model to associate the child models,.
In the view you can use fields_for or simple_fields_for (if simple_form gem is used) to list the child model fields in the subsequent steps,.
In every step rather than saving the object in the db, you can check if the object is valid or not using .valid? instead of save. At the final step you can use .save method.
With .valid? you can get the errors at each step and at the final step you can save all the records by creating the parent object.

How to get the last inserted id of embed form and store it in parent form : symfony

I have to parent form called EventForm and embed form called as RegisterForm. If your is not logged in means i want to show register form. Registration working fine with embed form. But after registration i want to store user id to parent table event.
I guess saveEmbeddedFroms() function called after parent form saved. So which function is suitable to update parent form. Can any one give me idea. How to do this.
When you call $form->save() on a form it saves the embedded forms as well but the embedded forms are saved after the main object.
I think what you could do is to write a preSave() function for your main form in which yu can get the embedded form, perform a save() o it (which will give you in return the saved object) and manually set the userid in the main form (remember to unset the embedded form so it is not saved twice).
You could also rethink the whole model because it looks a bit complicated ;) Do you reaaly have to use embedded forms here?

MVC child - parent on the same page

I'm pretty new to using MVC3 so hopefully the terms I'm using are all correct.
Basically I'm looking for a way (if possible!) to have a parent and child(s) record be added on the same page. I'm able to get the page to display correctly, but I'm unsure how to update the parent model.
In my Create view I have all the fields for the parent, and I'd also like to add the child records to the form as well.
I'm currently using Html.RenderPartial("CreateChildView") to display my Create child page within the parent.
I'm also using Html.RenderPartial("IndexChildView) to display my child records that have been added.
Where I'm stuck at is how to update the Parent model from the "CreateChildView" from above,
I've tried adding a submit button to the child view but I'm not getting the results I was hoping for.
the equivelent c# code that I'm kind of looking for is:
ParentObject.ChildObject.Add(new ChildObject)
and then a way to display this correctly
Thanks in Advance
Place both partials in div with ids. Post data with ajax from "CreateChildView" and update "IndexChildView" with response.

ASPNET MVC what do you call this, a partial view? Or something else?

I'm trying to google for info on a situation, but I dont know what it is called, so its hard to find results :)
I have a model with say 10 fields. But only some of those are shown on a particular view, lets say 3 of them: id, name, date. What do you call this kind of view that does not display the whole model? A partial view?
The problem is that because 7 fields are not sent to the view, when the Update action is called on the controller, those fields are null, and the DB gets updated with those 7 fields set to null.
This is called a ViewModel, which is obtained from the Model and is more adapted to the View.
This is still a view.
You are not specifying what kind of storage are you using, I'll make an example using the entity framework, but you can do it with whatever method you like.
The model for the view is an Entity. When you display the form in your view, only part of the fields in your model are editable. When the user submits, therefore, your model has only several fields filled in.
So, you should retrieve a new copy of the object you are editing from the database (call it "fromDb"), copy only the edited fields into the fromDb object, and save the fromDb object instead.
This way, all the fields are preserved.
Another way to do this, is to render hidden fields for all the fields that are not present. However this is NOT secure, as the user could edit those fields by hand (using the developer tools, or firebug).

Resources