2011-07-27

Taking off Anchor Tag in Drop Down List

A while ago, I encountered a issue about lookup column in a SharePoint list.
If lookups items are over 20 items, lookup column changes the visual.


Under 20 items:



Over 20 items (You can modify in the drop down list.) : 



I found the solution not to change the visual if lookups are over 20 items in bellow blog post.

Sharepoint lookups over 20 items solution?
(The solution is using DVDropDownList instead of FormField.)


I could resolve my issue referencing the post, but I encountered a new problem. The problem is that a lookup column is extended due to anchor tag in EditForm.aspx.



The resolution is using xlst to take off Anchor Tag.


The code is here. I add xslt code and fix SharePoint:DVDropDownList element.

<td width="400px" valign="top" class="ms-formbody">
  <xsl:variable name="lookup" select="substring-after(substring-before(/dsQueryResponse/Rows/Row/@test, '&lt;/a&gt;'), '&quot;&gt;')" />
  <SharePoint:DVDropDownList runat="server" id="ff4{$Pos}" __designer:bind="{ddwrt:DataBind('u',concat('ff4',$Pos),'SelectedValue','SelectedIndexChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@test')}" selectedvalue="{$lookup}" datasourceid="spdatasource1" datatextfield="Title" datavaluefield="ID" AppendDataBoundItems="True" CausesValidation="True"/>


Also see substring-before function and substring-after function.


2 comments:

  1. Excellent pieces. Keep posting such kind of information on your blog. I really impressed by your blog.

    ReplyDelete
  2. thanks a lot for this post, it's simply solved the problem i had

    ReplyDelete