Forums

 
ForumForumMainstream Foru...Mainstream Foru...DevelopersDevelopersNew PopupNew Popup
Previous Previous
 
Next Next
New Post
 6/16/2010 1:08 PM
 

Hey again,

The validation worked great from last time.

Now, I want to create a field (let's call it SPLIT_WITH) that's exactly like the ASSIGNED_TO field. It should work the same way, where I can click the ChangeButton, a pop-up appears, I select a name, then it populates the field. On my SPLIT_WITH field I have it running UserPopup() when the button is clicked. However, the value I select in the pop-up returns to the ASSIGNED_TO field. I tried modifying the Display Field for SPLIT_WITH, but I won't be able to get it to return to the correct field.

Now, it seems like I need to create a separate UserPopup javascript function, but I would like to know where to create it, and what parameters to pass to it. I've tried looking through the entire solution, but there are so many instances of the UserPopup function, that I don't know where to put my copy of it. Where should I create this function and how would I get it to return to the correct field?

Thanks for the help,

-Andrew

New Post
 6/16/2010 3:39 PM
 
 Modified By BDS_AT  on 6/16/2010 3:39:54 PM

Ok, I've gotten the popup to populate the correct field. I created the custom field with a ChangeButton, and when I click the button, it returns the function SplitPopup(). Now, that function does the exact same thing as UserPopup(), except it passes a different name into the parameter.

function SplitPopup()
{
return window.open('../Users/Popup.aspx', 'SplitPopup', 'width=600,height=400,resizable=1,scrollbars=1');
}

Now, within the popup, it calls the function SelectUser(sPARENT_ID, sPARENT_NAME). In that function, I put an if statement, checking if the name of the window was 'SplitPopup'. If so, then it would call SelectSplit and break, instead of going to SelectUser.

function SelectUser(sPARENT_ID, sPARENT_NAME)
{
if (window.name == 'SplitPopup') {
SelectSplit(sPARENT_ID, sPARENT_NAME);
return;
}
if ( window.opener != null && window.opener.ChangeUser != null )
{
window.opener.ChangeUser(sPARENT_ID, sPARENT_NAME);
window.close();
}
else
{
Original window has closed. User cannot be assigned.' + '\n' + sPARENT_ID + '\n' + sPARENT_NAME);
}
}

Obviously, SelectSplit performs the same function as SelectUser, but it sends the value to the correct field.

Now, I'm glad I got that done, but the problem is getting that field to load the same value after it's been saved. I can check in SQL that the value has been saved correctly, but when I go into the EditView again, it just pulls the Display Field's text again (in this case, the field just displays SPLIT_WITH in the EditView). Now, I can't remove the Display Field's text, because then it won't know how to populate the correct field. So how do I get it to load the value correctly and have the ability to save over it again?

Maybe you have a better way of doing this?

New Post
 6/16/2010 9:21 PM
 

You should have been able to accomplish the goal by just creating the new EditView record in the admin area. For the Data Field, specify the custom field where the ID will be stored, such as SPLIT_WITH_ID_C. For the Display Field, use an undefined field such as SPLIT_WITH_NAME. When the form is rendered, the invalid name should be retrieved from the Users table.

Using the javascript solution will work, but it would be better to use the helpers in the ~/Include/javascript/ModulePopupScripts.aspx file.

New Post
 6/17/2010 5:48 PM
 

The problem is that I did use the admin EditView. Take a look at my setting. I actually tried to return UserPopup(); originally, but that returned it to the ASSIGNED_TO field. Now, I wrote my own Javascript version of UserPopup called SplitPopup, and it saves correctly.

The following image is from the DetailView, and you can see that the Guid for the selected user is displayed. I have no problem just displaying the Guid (even though I would prefer to display the user's name, but you can help me with that later?)

This following image shows how it looks on the EditView, even though the value was saved to SQL, it doesn't pull up the value from the database, but displays the Display Field for the custom field.

How can I get it not to display SPLIT_WITH?

New Post
 6/17/2010 8:41 PM
 

The Field Type to use is ModulePopup. The ChangeButton is our old style that still works, but it does require all of the effort that you have gone through. ChangeButton also has the problem that the display field must be a valid field. With ModulePopup, this field can be invalid (but it still needs a name as do all ASP.NET controls). When we detect an invalid display field, we just lookup the name for the specified module. This is why using ModulePopup is better.

Previous Previous
 
Next Next
ForumForumMainstream Foru...Mainstream Foru...DevelopersDevelopersNew PopupNew Popup