How can I change the behavior when I click on a list item?
-
Wednesday, March 12, 2008 1:53 PM
Hi. I have a simple content type and a list that uses it. The default list view shows the Title column as a link with the ECB menu. When I click on that link, I go to the display form for the list item. I'd like the default action of that link instead to navigate to a URL based on some other content in the list item. So, say the list item has a ProjectName field and a ProjectSiteUrl field. I'd like the link text to be represented by the value of ProjectName and the link's target url to be the value of ProjectSiteUrl. How can I accomplish this?
thanks,
Chris
Answers
-
Wednesday, March 12, 2008 7:25 PM
The easiest way of doing this would be to use the DataFormWebPart within SP Designer. (Open a page in designer and drag your list to it from the DataSource list).
Then you can change the fields to link to whatever you want to.http://office.microsoft.com/en-us/sharepointdesigner/HA102403641033.aspx
-
Thursday, March 13, 2008 5:09 AM
Thanks for the reply. I'll definitely try that, but I didn't see your message until I already did it the hard way. Here's what I did...
I never knew exactly how the LinkTitle and LinkTitleNoMenu fields were rendered, but now I know. I looked at those SPFields' SchemaXml property in the debugger and copied it into my custom list definition's schema.xml file. I replaced the guids on them and gave them new names of "ProjectLinkTitle" and "ProjectLinkTitleNoMenu". Then I replaced the appropriate references to their names within their xml with the new "Project"-prefixed names. Then I found the <URL /> element in the ProjectLinkTitleNoMenu xml that was ultimately responsible for rendering the hyperlink's href, so I changed that to reflect the url that I really wanted to display here (<Column Name="MyUrlField" />). Finally, in my ViewFields element in my favorite view in the schema.xml, I replaced the existing LinkTitle fieldref with my new and improved ProjectLinkTitle fieldref. And it seems to work nicely!
Somehow it's more satisfying to dig through xml files for three hours instead of dragging and dropping and changing a few properties. Or at least that's how I try not to get depressed that there was an easier way.
thanks,
Chris
All Replies
-
Wednesday, March 12, 2008 7:25 PM
The easiest way of doing this would be to use the DataFormWebPart within SP Designer. (Open a page in designer and drag your list to it from the DataSource list).
Then you can change the fields to link to whatever you want to.http://office.microsoft.com/en-us/sharepointdesigner/HA102403641033.aspx
-
Thursday, March 13, 2008 5:09 AM
Thanks for the reply. I'll definitely try that, but I didn't see your message until I already did it the hard way. Here's what I did...
I never knew exactly how the LinkTitle and LinkTitleNoMenu fields were rendered, but now I know. I looked at those SPFields' SchemaXml property in the debugger and copied it into my custom list definition's schema.xml file. I replaced the guids on them and gave them new names of "ProjectLinkTitle" and "ProjectLinkTitleNoMenu". Then I replaced the appropriate references to their names within their xml with the new "Project"-prefixed names. Then I found the <URL /> element in the ProjectLinkTitleNoMenu xml that was ultimately responsible for rendering the hyperlink's href, so I changed that to reflect the url that I really wanted to display here (<Column Name="MyUrlField" />). Finally, in my ViewFields element in my favorite view in the schema.xml, I replaced the existing LinkTitle fieldref with my new and improved ProjectLinkTitle fieldref. And it seems to work nicely!
Somehow it's more satisfying to dig through xml files for three hours instead of dragging and dropping and changing a few properties. Or at least that's how I try not to get depressed that there was an easier way.
thanks,
Chris
-
Friday, June 06, 2008 7:09 PM
I cannot find the DataFormWebPart in SPD. The article is confusing also.
-
Friday, June 06, 2008 8:02 PM
DataForm WebPart is Insert Data View in Data view menu in the Designer , then choose source from let side -> click show data and then drag and drop fields in the data view webpart.
Thanks,
Isha Kapoor

