문제

I have a sharepoint 2007 list and it has 6 site columns, want to have two modes of newform.aspx page. When user clicks on Newitem, it should display only 3 site columns and there should a link to the advanced mode, when user clicks on the advanced mode link it should display all those 6 site columns and corresponding column values should be pre-populated if user already enters some information in the simple mode. And user should be able to go simple mode from the advanced mode.

I also want to display current user's name on the label is in the NewForm.aspx page

How it can be achieved? Dowe need to write some kind of javascript?

도움이 되었습니까?

해결책

You could do this fairly easily using SPUtility.js (full disclosure this is a library I maintain). You would probably put it all inside a Content Editor Web Part on the NewForm.aspx.

You would have your "advanced mode" link that would toggle showing/hiding the fields. Example using SPUtility.js:

SPUtility.GetSPField('Field A').Hide(); // or Show() after they click the link
SPUtility.GetSPField('Field B').Hide();
SPUtility.GetSPField('Field C').Hide();

Let me know if you choose to go this route and I can help with the rest.

다른 팁

JavaScript seems the way to go as you want to add some dynamic behavior to the page, but apparently you don't need any additional information from the server.

Your code will have to:

  • identify the 3 rows that need to be hidden
  • make them invisible (display:none or visibility:hidden)
  • toggle the visibility on click

JavaScript should also allow you to retrieve the current user name (either display name or better user account).

Another way to do this would be to use your EditForm to act as the 'advanced form' (assuming you want all 6 fields to be visible when a user is editing the list item). Then, a simple redirect when the user clicks 'OK' will take you to the edit/advanced form with the values you entered preserved.

For the redirect, the obvious question is how do I redirect to an item's edit form without the item's ID? (the ID is not created until the list item is saved). Try Marc D Anderson's SPServices Library - http://spservices.codeplex.com/. Marc has written a function to specifically address this problem -> $().SPServices.SPRedirectWithID.

You can also use Marc's SPServices library to display the current users name (and more) using the $().SPServices.SPGetCurrentUser utility.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top