无需点击即可展开所有切换

时间:2015-04-17 11:47:47

标签: javascript jquery html

javascript:

 <script>
        jQuery.noConflict();
        function toggleContactRow(rowId) {
                 var AccountImg = jQuery(document.getElementById(rowId + ":Img"));
                var ContactsRow = jQuery(document.getElementById(rowId + ":Contact"));
                 ContactsRow.show();
}
    </script>

Visualforce:

 <table id="tableAccount" class="list" border="0" cellpadding="0" cellspacing="0" >
                    <thead>
                        <tr class="headerRow">
                         <th class="actionColumn">Action</th>
                            <th>Account Name</th>
                            <th>Industry</th>
                            <th>Billing Country</th>
                            <th>Createdby</th>
                        </tr>
                    </thead>
                    <tbody>
                    <apex:repeat id="repeatAccount"
                        value="{!accountList}"
                        var="item">
                        <apex:variable var="acc" value="{!item.oAccount}" />   
                        <tr id="{!$Component.repeatAccount}:account" class="dataRow">
                         <td class="actionColumn">
                                <apex:inputcheckbox id="selectAccountRow"
                                    value="{!item.IsSelected}"
                                    onclick="javascript:toggleSelectAll(this, '{!$Component.repeatAccount}');"/>
                            </td>
                            <td class="dataCell">
                                <apex:outputLink id="linkShowHide" value="javascript:toggleContactRow('{!$Component.repeatAccount}')">
                                    <img id="{!$Component.repeatAccount}:Img" src="/s.gif" class="showContacts" border="0" height="11px" width="11px" style="padding-right: 4px;"/>
                                    <apex:outputField value="{!acc.Name}" />
                                </apex:outputLink>
                            </td>
                            <td class="dataCell"><apex:outputField value="{!acc.name}" /></td>
                            <td class="dataCell"><apex:outputField value="{!acc.Accountid}" /></td>
                            <td class="dataCell"><apex:outputField value="{!acc.Id}" /></td>
                        </tr>
                        <tr id="{!$Component.repeatAccount}:Contact" class="dataRow" style="display:none;">
                            <td colspan="100" style="padding:10px; padding-left: 45px;">
                                <h3>son opportunity</h3>
                                <br/>                                        
                                <apex:outputPanel layout="none">                                            
                                    <table id="tableAccountContacts" class="list" border="0" cellpadding="0" cellspacing="0">
                                        <thead>
                                            <tr class="headerRow">
                                                <th class="actionColumn">Action</th>
                                                <th>Name</th>
                                                <th>Email</th>
                                                <th>Phone</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                        <apex:repeat id="repeatAccountContacts"
                                            value="{!item.contactSet}"
                                            var="subitem">
                                            <apex:variable value="{!subitem.oContact}" var="con" />
                                            <tr class="dataRow">
                                                <td class="actionColumn"><apex:inputCheckbox id="selectContactRow" styleclass="ContactCheckbox" value="{!subitem.IsSelected}"/></td>
                                                <td class="dataCell"><apex:outputField value="{!con.id}" /></td>
                                                <td class="dataCell"><apex:outputField value="{!con.name}"/></td>
                                                <td class="dataCell"><apex:outputField value="{!con.accountid}" /></td>                                                        
                                            </tr>
                                        </apex:repeat>
                                        </tbody>
                                    </table>
                                </apex:outputPanel>
                            </td>
                        </tr>
                    </apex:repeat>
                    </tbody>
                </table>

目前,点击切换后,它会在td上展开。 在visualforce页面中,onload不接受。所以我必须在vf页面中保持onclick 但我想在打开页面时显示完全展开的切换

帮助我执行此操作enter image description here

我想在没有点击的情况下显示项目展开的切换 我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

简单节目

$( document ).ready(function() {
  $('.dataRow').show();
});

用于动画节目

$( document ).ready(function() {
  $('.dataRow').slideDown();
});