How to hide a row of table (or a list item) and update the datastore without reloading the page?
<p>I have a list of bookmarks displayed <a href="http://ting-1.appspot.com/" rel="nofollow">on a table</a>. I added a "hide" link to hide a bookmark that I don't want to see on the list but I still want to keep (table and the hide link show only if you are logged in).</p>

<p>Now I do it by getting the item from the database and by changing its "display" property to "False" and by rendering the page again.</p>

<p>I think this can better be done with javascript without reloading the page. I found several references to hide a row of a table but more than hiding I also need to write the new display property to the database. I don't understand how I can do this. What is the best way to do hide the row and write new display property to the database? Thanks.</p>

<p>This is the code I have now:</p>

<pre><code>#-----------main table------------#
            display = self.request.get("display")
            main_id = self.request.get("main_id")

            self.response.out.write("""&lt;table class="mytable"&gt;
            &lt;tr class="head"&gt;
            &lt;th  width="80%"&gt;links&lt;/th&gt;&lt;th&gt;edit tags&lt;/th&gt;
            &lt;/tr&gt;    
            """)        

            if display == "false":
                k = Main.get_by_id(int(main_id))
                k.display = False
                k.put()
                self.redirect("/useradminpage")

            query = Main.all()
            query.filter("owner", user)
            query.filter("display", True)
            query.order("-date")
            cursor = self.request.get("cursor")
            if cursor: query.with_cursor(cursor)
            e = query.fetch(100)
            cursor = query.cursor()

            for item in e:
                main_id = item.key().id()
                self.response.out.write("""
                    &lt;tr&gt;
                    &lt;td&gt;&lt;a href="%s" target="_blank"&gt;%s&lt;/a&gt;&lt;span class=small&gt; (%s) &lt;/span&gt;&lt;br /&gt;
                    &lt;span class=small&gt;%s&lt;/span&gt;
                    &lt;a href="/edit?main_id=%s"&gt;&lt;span class="small"&gt;(edit)&lt;/span&gt;&lt;/a&gt;
                    &lt;a href="/useradminpage?main_id=%s&amp;display=false"&gt;&lt;span class="small"&gt;(hide)&lt;/span&gt;&lt;/a&gt;
                    &lt;a href="/comment?main_id=%s"&gt;&lt;span class="small"&gt;(comments)&lt;/span&gt;&lt;/a&gt;

                    &lt;td&gt;&lt;a href="/tc?url=%s&amp;main_id=%s&amp;user_tag_list=%s" title="edit tags"&gt;%s&lt;/a&gt;&lt;/td&gt;
                    &lt;/tr&gt;
                    """ %
                    tuple([item.url,
                    item.title, 
                    urlparse(item.url).netloc,

                    f1.truncate_at_space(item.pitch),

                    main_id,
                    main_id,
                    main_id,

                    item.url,  
                    main_id,  
                    (", ".join(item.tag_list)),
                    (", ".join(item.tag_list)),
                    ]))


            self.response.out.write("""&lt;/table&gt;""")    
</code></pre>

<p><strong>Update</strong></p>

<p>Trying <code>style.display</code> in <a href="http://stackoverflow.com/questions/7669256/how-to-hide-a-row-of-table-or-a-list-item-and-update-the-datastore-without-relo/7669753#7669753">RobG's answer</a>; but the following code does not work:  </p>

<pre><code>...
    for item in e:
        main_id = item.key().id()
        self.response.out.write("""
            &lt;div&gt;
            &lt;tr&gt;
            &lt;td&gt;&lt;a href="%s" target="_blank"&gt;%s&lt;/a&gt;&lt;span class=small&gt; (%s) &lt;/span&gt;&lt;br /&gt;
                &lt;span class=small&gt;%s&lt;/span&gt;
            &lt;a href="/edit?main_id=%s"&gt;&lt;span class="small"&gt;(edit)&lt;/span&gt;&lt;/a&gt;
            &lt;a href="/useradminpage?main_id=%s&amp;display=false" onclick="this.parentNode.style.display = "none";&gt;&lt;span class="small"&gt;(hide)&lt;/span&gt;&lt;/a&gt;
            &lt;a href="/comment?main_id=%s"&gt;&lt;span class="small"&gt;(comments)&lt;/span&gt;&lt;/a&gt;
            &lt;td&gt;&lt;a href="/tc?url=%s&amp;main_id=%s&amp;user_tag_list=%s" title="edit tags"&gt;%s&lt;/a&gt;&lt;/td&gt;
            &lt;/tr&gt;
            &lt;/div&gt;

...
</code></pre>

<p><strong>UPDATE</strong></p>

<p>Trying <a href="http://stackoverflow.com/questions/7669256/how-to-hide-a-row-of-table-or-a-list-item-and-update-the-datastore-without-relo/7669753#7669753">RobG's edited answer</a>. In this case, when I click the hide button, the row is hidden for a moment and then it is back again. I don't understand why. I paste below the code including the holding table:</p>

<pre><code>#-----------holding table start--------#
            self.response.out.write("""
            &lt;table border="0" cellpadding="5" cellspacing="10" &gt;
            &lt;tbody&gt;
            &lt;tr&gt;
            &lt;td&gt;""")
            self.response.out.write("""&lt;td style="vertical-align:top"&gt;""")
#-----------tags table start--------#                                   
            self.response.out.write("""&lt;table class="mytable"&gt;
            &lt;tbody&gt;
            &lt;tr class="head"&gt;
            &lt;th&gt;tags&lt;br /&gt;
            &lt;a href="/useradminpage?order=alpha"&gt;&lt;span class=small&gt;alpha&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
            &lt;a href="/useradminpage?order=date"&gt;&lt;span class=small&gt;newest&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
            &lt;a href="/useradminpage?order=popular"&gt;&lt;span class=small&gt;popular&lt;/span&gt;&lt;/a&gt;
            &lt;/th&gt;
            &lt;/tr&gt;
            """)      

            if order_by == "popular":
                for tag in most_used:
                    self.response.out.write("""
                    &lt;tr&gt;&lt;td&gt;&lt;a href="/tag?tag=%s"&gt;%s&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
                    """ %
                    (tag, tag))                
            else:
                for tag in unique_tags:                
                    self.response.out.write("""
                    &lt;tr&gt;&lt;td&gt;&lt;a href="/tag?tag=%s"&gt;%s&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
                    """ %
                    (tag, tag))

            self.response.out.write("""&lt;/table&gt;""")  

            #holding table first column end
            self.response.out.write("""&lt;/td&gt;""")

            #holding table second column start
            self.response.out.write("""&lt;td style="vertical-align:top"&gt;""")
#-----------main table------------#
            display = self.request.get("display")
            main_id = self.request.get("main_id")

            self.response.out.write("""&lt;table class="mytable"&gt;
            &lt;tr class="head"&gt;
            &lt;th  width="80%"&gt;links&lt;/th&gt;&lt;th&gt;edit tags&lt;/th&gt;
            &lt;/tr&gt;    
            """)        

            query = Main.all()
            query.filter("owner", user)
            #query.filter("display", True)
            query.order("-date")
            cursor = self.request.get("cursor")
            if cursor: query.with_cursor(cursor)
            e = query.fetch(100)
            cursor = query.cursor()

            for item in e:
                main_id = item.key().id()
                self.response.out.write("""

                    &lt;tr&gt;
                      &lt;td&gt;&lt;a href="%s" target="_blank"&gt;%s&lt;/a&gt;&lt;span class=small&gt; (%s) &lt;/span&gt;&lt;br /&gt;
                        &lt;span class=small&gt;%s&lt;/span&gt;
                        &lt;a href="/edit?main_id=%s"&gt;&lt;span class="small"&gt;(edit)&lt;/span&gt;&lt;/a&gt;
                        &lt;a href="/useradminpage?main_id=%s&amp;display=false" 

                          onclick="this.parentNode.parentNode.style.display = 'none';"&gt;

                        &lt;span class="small"&gt;(hide)&lt;/span&gt;&lt;/a&gt;
                        &lt;a href="/comment?main_id=%s"&gt;&lt;span class="small"&gt;(comments)&lt;/span&gt;&lt;/a&gt;
                      &lt;td&gt;&lt;a href="/tc?url=%s&amp;main_id=%s&amp;user_tag_list=%s" title="edit tags"&gt;%s&lt;/a&gt;&lt;/td&gt;
                    &lt;/tr&gt;

                    """ %
                    tuple([item.url,
                    item.title, 
                    urlparse(item.url).netloc,
                    f1.truncate_at_space(item.pitch),
                    main_id,
                    main_id,
                    main_id,
                    item.url,  
                    main_id,  
                    (", ".join(item.tag_list)),
                    (", ".join(item.tag_list)),
                    ]))

            self.response.out.write("""&lt;/tbody&gt;&lt;/table&gt;""")    

            #holding table end 
            self.response.out.write('&lt;a href="/useradminpage?cursor=%s"&gt;More Results&lt;/a&gt;' % cursor)
            self.response.out.write("""&lt;/td&gt;&lt;/tr&gt;""")
            self.response.out.write("""&lt;/tbody&gt;&lt;/table&gt;""")
            self.response.out.write("""&lt;/div&gt;""")
</code></pre>
