0

Sharepoint2010 サイトの QuickLaunchMenu を変更して、アコーディオン スタイルを使用しようとしています。

現在選択されているアイテムを取得するにはどうすればよいですか? 現在の (アクティブな) nav-item に css クラスを追加する可能性はありますか? 3 番目の階層レベルを追加するにはどうすればよいですか?

これは私のjQueryコードです:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            $("#s4-leftpanel-content li.static>ul.static").each(function(){
                $(this).hide();
            });
            $("#s4-leftpanel-content ul.root>li.static>a").click(function(ev){
                //ev.preventDefault();
                var child = $(this).parent().children('ul');            
                $("#s4-leftpanel-content li.static>ul.static").each(function(){
                        $(this).hide();            
                });
                child.toggle();
            });
            //disable heading click
            $("#s4-leftpanel-content ul.root>li.static>a").toggle(
                function () {},
                function () {}
            );
        });
    </script>

これは私のクイック起動コントロールです:

<SharePoint:UIVersionedContent UIVersion="4" runat="server">
                        <ContentTemplate>
                            <SharePoint:AspMenu id="V4QuickLaunchMenu" runat="server" EnableViewState="false" 
                                DataSourceId="QuickLaunchSiteMap" 
                                UseSimpleRendering="true" 
                                UseSeparateCss="false" 
                                SelectStaticItemsOnly="true" 
                                CustomSelectionEnabled="true" 
                                Orientation="Vertical" 
                                StaticDisplayLevels="3" 
                                MaximumDynamicDisplayLevels="2" 
                                SkipLinkText=""
                                CssClass="s4-ql">
                            </SharePoint:AspMenu>
                        </ContentTemplate>
                    </SharePoint:UIVersionedContent>

どんな助けでも大歓迎です。

ありがとう!

4

2 に答える 2

1

AspMenu は Menu クラス (WebControls 名前空間の一部) から継承され、

アクティブな選択については、SelectedItem プロパティを参照してください

msdn.microsoft.com/EN-US/library/0f4wwt2y

CSS には、StaticSelectedStyle、DynamicSelectedSytle、LevelSelectedSytles があります。あなたの場合、3 レベルの静的メニューと 2 レベルの動的メニューを作成しました。CSS スタイルの StaticSelectedStyle と DynamicSelectedSytle を見てください。

ところで、動的メニューの最大 2 レベルの作成に制限があるため、3 レベルを作成できないのはそのためだと思います。

    <DynamicSelectedStyle
        BackColor="color name|#dddddd"
        BorderColor="color name|#dddddd"
        BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|
            Groove|Ridge|Inset|Outset"
        BorderWidth="size"
        CssClass="string"
        Font-Bold="True|False"
        Font-Italic="True|False"
        Font-Names="string"
        Font-Overline="True|False"
        Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|
            Medium|Large|X-Large|XX-Large"
        Font-Strikeout="True|False"
        Font-Underline="True|False"
        ForeColor="color name|#dddddd"
        Height="size"
        HorizontalPadding="size"
        ItemSpacing="size"
        OnDisposed="Disposed event handler"
        VerticalPadding="size"
        Width="size"
    />
    <StaticSelectedStyle
        BackColor="color name|#dddddd"
        BorderColor="color name|#dddddd"
        BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|
            Groove|Ridge|Inset|Outset"
        BorderWidth="size"
        CssClass="string"
        Font-Bold="True|False"
        Font-Italic="True|False"
        Font-Names="string"
        Font-Overline="True|False"
        Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|
            Medium|Large|X-Large|XX-Large"
        Font-Strikeout="True|False"
        Font-Underline="True|False"
        ForeColor="color name|#dddddd"
        Height="size"
        HorizontalPadding="size"
        ItemSpacing="size"
        OnDisposed="Disposed event handler"
        VerticalPadding="size"
        Width="size"
    />

これを見てください。 http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.aspmenu_members.aspx

http://msdn.microsoft.com/en-us/library/ms476607.aspx

于 2011-05-23T15:18:31.480 に答える
1

こんにちは、asp コントロール属性を変更せずに sharepoint Quicklaunch のアコーディオンを作成する 1 つの方法を見つけました。これが私が働いた方法です。

<script type="text/javascript" src="/_layouts/Scripts/jquery-1.4.4.min.js"></script>    
<script type="text/javascript" src="/_layouts/Scripts/jquery.easing.js"></script>
<script type="text/javascript" src="/_layouts/Scripts/jquery.dimensions.js"></script>
<script type="text/javascript" src="/_layouts/Scripts/jquery.accordion.js"></script>
<script type="text/javascript" src="/_layouts/Scripts/navaccord.js"></script>

「navaccord.js」ファイルに追加された以下のコード

jQuery().ready(function(){      
    // second simple accordion with special markup
    jQuery('.root ').accordion({
        header: '.menu-item',
        navigation: true,
        event: 'click',         
        animated: 'easeslide',
        active: '.tab4',
        selectedClass: 'active'

    });

    // bind to change event of select to control first and seconds accordion
    // similar to tab's plugin triggerTab(), without an extra method
    var accordions = jQuery('.root');

    jQuery('#switch select').change(function() {
        accordions.accordion("activate", this.selectedIndex-1 );
    });
    jQuery('#close').click(function() {
        accordions.accordion("activate", -1);
    });
    jQuery('#switch2').change(function() {
        accordions.accordion("activate", this.value);
    });
    jQuery('#enable').click(function() {
        accordions.accordion("enable");
    });
    jQuery('#disable').click(function() {
        accordions.accordion("disable");
    });
    jQuery('#remove').click(function() {
        accordions.accordion("destroy");
        wizardButtons.unbind("click");
    });
});
$(function () {
$("ul>li>ul>li>a").removeClass("menu-item");
$("ul>li>ul").css({'display':'none', 'height':''});
        });

これがすべての人に役立つことを願っています。唯一の問題は、選択したページの読み込み後にアコーディオンが折りたたまれることです。

于 2011-08-24T10:39:46.317 に答える