none
custom field type inheriting spfieldmulticolumn dispaly html as text RRS feed

  • Question

  • from fldtypes_SPFieldObjectLookup.xml:

         <RenderPattern Name="DisplayPattern">
           <Switch>
             <Expr>
               <Column/>
             </Expr>
             <Case Value="">
             </Case>
             <Default>
               <HTML><![CDATA[<a href="]]></HTML>
               <Column SubColumnNumber="2" HTMLEncode="FALSE"/>
               <HTML><![CDATA[">]]></HTML>
               <Column SubColumnNumber="3" HTMLEncode="FALSE"/>
               <HTML><![CDATA[</a>]]></HTML>
             </Default>
           </Switch>
         </RenderPattern>

    the <a> tag in the spfieldurl displays well.

    The difference in rendered html is the div tag marked yellow. 

    can anyone reproduce this issue with a SPFieldMultiColumn field?

    Or, is this just a browser issue?



    • Edited by GuYuming Tuesday, July 30, 2019 9:17 AM
    Tuesday, July 30, 2019 9:07 AM

All replies

  • I have no onpremise environment...

    Do you mean that the field definition doesn't contain div but the html rendered a div tag?

    As you said, it may be caused by web browser or it may be the default behavior of SPFieldMultiColumn  


    Justin Liu Office Apps & Services MVP, MCSE
    Senior Software Engineer
    Please Vote and Mark as Answer if it helps you.

    Wednesday, July 31, 2019 1:22 AM
  • Hi Yuming,

    As a workaround, we can add the code below into content editor web part to solve this issue.

    <script src="https://code.jquery.com/jquery-1.12.4.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(function () {
    	var fieldIndex=0;
    	$(".ms-listviewtable tr th").each(function(i){ 
    		if($(this).text().indexOf("SPFieldObjectLookup1")!=-1){
    			fieldIndex=i;
    		}       
    	});
    	$(".ms-listviewtable tr").each(function(i){
    		if(i>0){			
    			var fieldValue=$(this).children("td").eq(fieldIndex).find(".ms-rtestate-field").text();
    			if(fieldValue!=""){
    				$(this).children("td").eq(fieldIndex).find(".ms-rtestate-field").html(fieldValue); 
    			}
    		}
    	});
    
    });
    </script>

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Wednesday, July 31, 2019 9:21 AM
    Moderator
  • Thanks for your effort and the code, I will try it when needed, such as a customer requirement. I won't close this thread since I hope it could be fixed in future (If you guys can reproduce). If not with RenderPattern technology, maybe a server side solution such as xslt before I give up the SPFieldMultiColumn.
    • Edited by GuYuming Wednesday, July 31, 2019 10:02 AM
    Wednesday, July 31, 2019 9:58 AM
  • Hi,

    Did you try to use code below in PrederPattern?

    <HTML><![CDATA[&lt;a href="]]></HTML>
    <Column SubColumnNumber="2" HTMLEncode="FALSE"/>
    <HTML><![CDATA["&gt;]]></HTML>
    <Column SubColumnNumber="3" HTMLEncode="FALSE"/>
    <HTML><![CDATA[&lt;/a&gt;]]></HTML>

    Or try to set HTMLEncode to "TRUE".

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Thursday, August 1, 2019 8:21 AM
    Moderator
  • I don't think why I would try this, you just need to edit html with IE developer tools to see whether an anchor tag inside <td><div class="" dir=""> displays well. 

    my test is that if I delete the <div> tag, anchor displays well.

    I don't think escape the html data inside [![CDATA[]] will make the <div> not rendered at server side.

    I suggest that if you cannot find the code logic about how the RenderPattern is rendered. Just escalate the thread. I know that Microsoft FTE has C++ source code.

    Update: and I escape the code with IE developer tools as you suggest, not with RenderPattern. it does not fix.

    • Edited by GuYuming Thursday, August 1, 2019 9:27 AM
    Thursday, August 1, 2019 8:56 AM
  • Hi Yuming,

    Unfortunately, we can't see the source code for the policy, hope you understand.

    As a workaround, you can use my code above to solve it.

    In this case, I suggest you submit a ticket to get more helps.

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Monday, August 5, 2019 8:59 AM
    Moderator