Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 25064

Custom Field xsl style in ListViewByQuery does not work.

$
0
0

Hi,

I'm displaying my list with custom fields inside a WebPart using ListViewByQuery control:

public override void RenderControl(HtmlTextWriter writer)
        {
            var currentItemId = SPContext.Current.ItemId;
            if (currentItemId > 0)
            {
                var list = SPContext.Current.Web.Lists["MyList"];

                var query =
                    String.Format(
                        "<Where><Eq><FieldRef Name='MyField' LookupId='TRUE' /><Value Type='Lookup'>{1}</Value></Eq></Where>",
                        currentItemId);

                var listQuery = new SPQuery(list.Views["MyView"]) { Query = query };

                var lvSurveys = new ListViewByQuery {List = list, Query = listQuery};

                EnsureChildControls();
                lvSurveys.RenderControl(writer);
                RenderChildren(writer);
            }
        }

XSL template for my custom field:

<xsl:template match ="FieldRef[@FieldType='Survey']" mode="Text_body"><xsl:param name="thisNode" select="."/><xsl:value-of select="format-number(substring-before($thisNode/@*[name()=current()/@Name], '%%'), '000%')" /></xsl:template>

XSL formatting works fine for all list views, but fails to apply to ListViewByQuery control.

Any ideas why (ie: different mode, etc.)?




Viewing all articles
Browse latest Browse all 25064

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>