Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8180099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:08:39+00:00 2026-06-07T00:08:39+00:00

I have the following html table <table id={64ED3A94-5833-4CC7-869F-CCE583B498BE} class=ms-listviewtable width=100% cellspacing=0 cellpadding=1 border=0 xmlns:o=urn:schemas-microsoft-com:office:office

  • 0

I have the following html table

   <table id="{64ED3A94-5833-4CC7-869F-CCE583B498BE}" class="ms-listviewtable"
            width="100%" cellspacing="0" cellpadding="1" border="0" 
            xmlns:o="urn:schemas-microsoft-com:office:office" dir="none">
       <tbody id="tbod23-1__" isloaded="true" style="display: none;"></tbody>
       <tbody id="tbod23-2__" isloaded="true" style=""></tbody>
       <tbody id="tbod23-3__" isloaded="true" style="display: none;"></tbody>
       <tbody id="tbod23-4__" isloaded="true" style=""></tbody>
       <tbody id="tbod23-5__" isloaded="true" style="display: none;"></tbody>
       <tbody id="tbod23-6__" isloaded="true" style="display: none;"></tbody>
       <tbody id="tbod23-7__" isloaded="true" style="display: none;"></tbody>
    </table>

This table is autogenerated by a sharepoint xsltlistviewwebpart (didnt post in sharepoint as the question is more jquery+html related).

this is a treeview with nodes, when i expand a collapsed node it changes style from

style="display: none;" 

to

style=""

The problem: the webpart does not remember which nodes were collapsed, so on each postback it resets all to expanded. What I need to do, is to remember the node state (expanded or collapsed) in a jquery cookie, and to retrieve it on postbacks (so, to persist the node state).

So far I got:

<script type="text/javascript">
_spBodyOnLoadFunctionNames.push("RememberClickedState");

function RememberClickedState()
{
var dv = $('.ms-listviewtable');
var items = [];
items = dv.find('tbody[id^="tbod"]');
$.cookie("itemListState", items);
    alert(items[0]);
    alert(items[1]);
 }

 </script>

Can anyone please provide some pointers on how to do this. Im a bit dazed and confused about the events themselves, on page_load I should save the cookie but also retrieve it somehow.

Also “items” array stored all 7 elements which is good, but when i try alert(items[0]); I get undefined.

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T00:08:40+00:00Added an answer on June 7, 2026 at 12:08 am

    I suggest you to create string of this and then parse this string back… kind of like that:

    var items = '';
    function RememberClickedState() {
        $('.ms-listviewtable tbody').each(function(){
            tid = $(this).attr('id');
            tvisible = $(this).is(':visible');
            items += tid+':'+tvisible+','
        })
        //$.cookie("itemListState", items);
        $('body').append(items+'<br/>');
    }
    function RestoreClickedState() {
        //string = $.cookie("itemListState")
        var string = items; //temporary
        var cookies = string.split(',');
        $.each(cookies, function(i, val){
            val = val.split(':');
            show = (val[1] == 'true' ? true:false);
            item = $('.ms-listviewtable').find('#'+val[0]);
            show ? item.show() : item.hide();
            $('body').append('#'+val[0]+' is '+ 'display:'+show+'<br/>');
        })
    }
    $(document).ready(function(){
        RememberClickedState();
        RestoreClickedState();
    })
    

    Here is DEMO:
    http://jsfiddle.net/MYexv/3/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following HTML: <table id=MwDataList class=data width=100% cellspacing=10px> .... <td class=centerText style=height:
I have the following HTML table: <table style=width: 100%;> <tr> <td class=title_bar_left_border></td> <td class=title_bar_middle></td>
I have following html: <table width=100%;> <tr><hr style=width:100%;></hr></tr> <tr> <span style=float:left>abc</span> <span class=noindex style=float:right>PageID</span>
I have the following html page: <body> <div class=hide1 style=width:1000px; height:1000px;> <table width=100% border=0
I have the following HTML code: <table id=userPlaylistTable cellspacing=0 cellpadding=0> <div class=numCellWrapper> <div class=listArrow
I have the following HTML code : <table class=report width=100%> <thead> </thead> <tbody> <tr
I have the following HTML: <div style=30px;> <table width=100%;> <tr> <td> <SELECT name=guidelinks> <OPTION
I have the following HTML (a snippet): <td class=ms-vb-title height=100%> <table class=ms-unselectedtitle onmouseover=OnItem(this) ctxname=ctx1
I have the following HTML table format: <table style=width: 100%;> <tr> <td> //How to
I have following HTML table: <form method=post action=update-table.php> <table class=table-data style=width: 960px;> <thead> <tr>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.