2013-02-19 42 views
6

मैं डॉटनेटनेट के लिए डीडीआर ट्रीव्यू मेनू पर काम कर रहा हूं ताकि केवल चयनित रूट आइटम और उसके बच्चे नोड को विस्तारित किया जा सके। यहां मैं जो हासिल करने की कोशिश कर रहा हूं वह यहां है। (बाएं लंबवत मेनू) कोई सलाह कृपया?डीडीआर ट्रीव्यू मेनू मेनू चयनित रूट और उसके बच्चे नोड

enter image description here

यह xslt कोड है और वर्तमान में सभी जड़ आइटम प्रदर्शित कर रहा है।

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    <xsl:output method="html"/> 
    <xsl:param name="ControlID" /> 
    <xsl:param name="Options" /> 
    <xsl:template match="/*"> 
    <xsl:apply-templates select="root" /> 
    </xsl:template> 
    <xsl:template match="root"> 
    <xsl:if test="node"> 
     <ul class="treeview filetree" id="{$ControlID}"> 
     <xsl:apply-templates select="node" /> 
     </ul> 
     <script type="text/javascript"> 
     jQuery(function($) { 
      $("#<xsl:value-of select="$ControlID" />").treeview(
      <xsl:value-of select="$Options" disable-output-escaping="yes" /> 
     ); 
     }); 
     </script> 
    </xsl:if> 
    </xsl:template> 
    <xsl:template match="node"> 
    <li> 
     <xsl:if test="node and (@depth != 0 or @breadcrumb = 1)"> 
     <xsl:attribute name="class">open</xsl:attribute> 
     </xsl:if> 
     <xsl:choose> 
     <xsl:when test="@enabled = 0"> 
      <xsl:value-of select="@text" /> 
     </xsl:when> 
     <xsl:otherwise> 
      <a href="{@url}"> 
      <xsl:choose> 
       <xsl:when test="@selected=1"> 
       <xsl:attribute name="class">selected breadcrumb</xsl:attribute> 
       </xsl:when> 
       <xsl:when test="@breadcrumb=1"> 
       <xsl:attribute name="class">breadcrumb</xsl:attribute> 
       </xsl:when> 
      </xsl:choose> 
      <xsl:value-of select="@text" /> 
      </a> 
     </xsl:otherwise> 
     </xsl:choose> 
     <xsl:if test="node"> 
     <ul style="list-item-style:none"> 
      <xsl:apply-templates select="node" /> 
     </ul> 
     </xsl:if> 
    </li> 
    </xsl:template> 
</xsl:stylesheet> 
+5

आपको प्रश्न में xml जोड़ना चाहिए। – Sandro

+1

क्या आप बच्चे की वस्तुओं या बस बाईं ओर अधिकांश कॉलम में संपूर्ण पंक्तियों (होम, के बारे में, सेवा/स्थान और संपर्क कॉलम सहित) को छिपाने की कोशिश कर रहे हैं? – dlp

उत्तर

0

यदि आपको केवल रूट आइटम मिल रहे हैं, तो आप मेनू के लिए NodeSelector परिभाषित करना चाहेंगे। मेरा मानना ​​है कि शॉर्टेंड वैल्यू RootChildren आपको वही देगा जो आप चाहते हैं।

+0

इस मुद्दे को मैंने कैसे हल किया। हालांकि, आपके उत्तर ने भी मदद की। – user1781367

1

यदि आप उस इनपुट कोड का उदाहरण प्रदान करते हैं जो आप बदलना चाहते हैं तो यह मदद करेगा।

मुझे लगता है इसके मूल रूप से कुछ इस तरह:

<root> 
    <node enabled="1" depth="1" text="Service" selected="true" breadcrumb="0"/> 
    <node> 
    <node> 
     <node/> 
    </node> 
    </node> 
    <node> 
    <node/> 
    </node> 
    <node/> 
</root> 

आप पहले टेम्पलेट मैचों की और उन पहले अगर तत्व को छोड़ सकते हैं और सीधे ही कुछ इस तरह से मेल खाते हैं, परीक्षण के बिना क्या आप में रुचि रखते हैं। स्रोत XML यह वास्तव में बाहर काम करने के आप यहाँ कर की कोशिश कर रहे हैं क्या मुश्किल है बिना

<!-- ... --> 
<!-- process only "root" elements that have at least one "node" element --> 
<xsl:template match="/root[node]"> 
    <ul class="treeview filetree" id="{$ControlID}"> 
    <xsl:apply-templates select="node" /> 
    </ul> 
    <!-- ... --> 
</xsl:template> 
<xsl:template match="node"> 
    <!-- ... --> 
</xsl:template> 
1

, लेकिन मैं कहेंगे मुख्य कारण आप सभी नोड्स हो रही है: चाल करना चाहिए 012 से मेल खाने के लिए टेम्पलेटतत्व रिकर्सिव है और वंशजों को छुपा नहीं है। node टेम्पलेट (list-item-style से display) के अंत में तत्व पर विशेषता पर display:none जोड़ें (या list-item-style से display पर बदलें), तो आप जो चाहते हैं उसे प्राप्त कर सकते हैं।