Confusion with related items
- Alexey Babin
- Posts: 23
- Joined: Wed May 11, 2016
- Contact:
I've faced to such problem: I'm using related items list in non-grid mode. And I need to be able to add new children on NEW parent's form (for new parent) and on EDIT parent's form (for existing parent). The parent's ID translation from Parens form provided by JS code on children's NEW form. The code is
$('#_fd_parent_temp > input').val(window.top.fd._tempParentId()); //This part for create new item from NEW parent
//this code for create new child for existing item via EDIT form.
var parentID = fd.getSourceID();
if (parentID) {
fd.field('ParentId').control().value(parentID);
}
So the problem is in ListView of related items, that is placed at Parent's NEW form. It appears when: 1. I create new parent (a.e. with ID = 1) (with or without children - at this moment it does not make sense) 2. I open existing parent (with ID = 1) 3. I add another children to this parent, save it, and close Edit form 4. I open new parent form, and see on the blank form previously created children (that has ParentID = 1) 5. ParentID of children described in previous point changes to 1. This probem disappear when I clear browser cookies after editing parent item, but it's not the case for users.
$('#_fd_parent_temp > input').val(window.top.fd._tempParentId()); //This part for create new item from NEW parent
//this code for create new child for existing item via EDIT form.
var parentID = fd.getSourceID();
if (parentID) {
fd.field('ParentId').control().value(parentID);
}
So the problem is in ListView of related items, that is placed at Parent's NEW form. It appears when: 1. I create new parent (a.e. with ID = 1) (with or without children - at this moment it does not make sense) 2. I open existing parent (with ID = 1) 3. I add another children to this parent, save it, and close Edit form 4. I open new parent form, and see on the blank form previously created children (that has ParentID = 1) 5. ParentID of children described in previous point changes to 1. This probem disappear when I clear browser cookies after editing parent item, but it's not the case for users.
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
Hi Alex,
Try to add the condition into the child form:
Try to add the condition into the child form:
Code: Select all
if (window.top.fd._formType() == 'New') {
$('#_fd_parent_temp > input').val(window.top.fd._tempParentId());
} else {
var parentID = fd.getSourceID();
if (parentID) {
fd.field('ParentId').control().value(parentID);
}
}
- Alexey Babin
- Posts: 23
- Joined: Wed May 11, 2016
- Contact:
Thanks a lot! Now works great!
-
- Information
-
Who is online
Users browsing this forum: No registered users and 7 guests