Sharepoint SPGridView control is expanded by default

The Sharepoint SPGridView control seems to be rendered as expanded sometimes, although it should be collapsed.

Here is a javascript function to fix this issue:

function spGridViewFixExpandedGroups(gridviewId) {
    var gridview = $("[id$='" + gridviewId + "']");
    var links = gridview.find("tr[isexp='true'] a[title='Expand/Collapse']");;

Simply call the script upon page load. Note: The script requires the jQuery library to be included.

2 Responses to “Sharepoint SPGridView control is expanded by default”

  1. 1 Trilochan Nayak February 17, 2012 at 10:18 am

    It solved my problem

  2. 2 July 21, 2014 at 7:21 pm

    Aw, this was a very good post. Spending some time and actual effort to create a top
    notch article… but what can I say… I procrastinate a lot and never manage to
    get anything done.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

%d bloggers like this: