﻿<?xml version="1.0" encoding="utf-8"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Intersoft Community - WebGrid Enterprise - How to use server code Collapse WebGrid (SelfReferencing)</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-to-use-server-code-Collapse-WebGrid-SelfReferencing/</link><description /><generator>http://www.intersoftsolutions.com</generator><language>en</language><copyright>Copyright 2002 - 2015 Intersoft Solutions Corp. All rights reserved.</copyright><ttl>60</ttl><item><title>How to use server code Collapse WebGrid (SelfReferencing)</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-to-use-server-code-Collapse-WebGrid-SelfReferencing/</link><pubDate>Fri, 07 Nov 2014 02:45:18 GMT</pubDate><dc:creator>Hans</dc:creator><category>WebGrid</category><category>Collapse</category><description>Hello,&lt;br&gt;&lt;br&gt;I’m glad that you have found the solution for your current scenario.&lt;br&gt;&lt;br&gt;Should you have further question, please do not hesitate to contact us.&lt;br&gt;&lt;br&gt;Thank you.&lt;br&gt;&lt;br&gt;Regards,&lt;br&gt;Hans K.</description></item><item><title>How to use server code Collapse WebGrid (SelfReferencing)</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-to-use-server-code-Collapse-WebGrid-SelfReferencing/</link><pubDate>Wed, 05 Nov 2014 07:13:02 GMT</pubDate><dc:creator>rogerchen.tangshuo@gmail.com</dc:creator><category>WebGrid</category><category>Collapse</category><description>&lt;p&gt;I can solution this issue, js code like this:&lt;/p&gt;&lt;pre&gt;        // 一键折叠或一键展开        function doCollapseExpand(ctl) {
            var grid = ISGetObject("wg_cwbt");

            if (ctl.value == "一键折叠") {
                document.getElementById("hid_expand_flag").value = "0";
                ctl.value = "一键展开"

                // select the first row
                var rowCount = grid.RootTable.GetRowsCount();

                for (var i = 0; i &amp;lt; rowCount; i++) {
                    var row = grid.RootTable.GetRow(i);
                    &lt;b&gt;if(row != null)&lt;/b&gt;
                    {
                        if (row.IsSelfRefRow) { // &amp;amp;&amp;amp; SelfRefExpanded
                            row.CollapseSelfRefRow();
                        }
                    }
                }
            }
            else {
                document.getElementById("hid_expand_flag").value = "1";
                ctl.value = "一键折叠"

                grid.Refresh();
            }
            return;
        }&lt;/pre&gt;&lt;p&gt;Regards,&lt;/p&gt;&lt;p&gt;RogerChen&lt;/p&gt;</description></item><item><title>How to use server code Collapse WebGrid (SelfReferencing)</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-to-use-server-code-Collapse-WebGrid-SelfReferencing/</link><pubDate>Wed, 05 Nov 2014 06:43:49 GMT</pubDate><dc:creator>rogerchen.tangshuo@gmail.com</dc:creator><category>WebGrid</category><category>Collapse</category><description>&lt;p&gt;thank you for your reply, i use js code like this:&lt;/p&gt;&lt;pre&gt;    // 一键折叠或一键展开        function doCollapseExpand(ctl) {
            var grid = ISGetObject("wg_cwbt");

            if (ctl.value == "一键折叠") {
                document.getElementById("hid_expand_flag").value = "0";
                ctl.value = "一键展开"

                // select the all row
                var rowCount = grid.RootTable.GetRowsCount();

                for (var i = 0; i &amp;lt; rowCount; i++) {
                    var row = grid.RootTable.GetRow(i);

                    // only expand the first row if :
                    // 1) It's a SelfReference row type
                    // 2) It has been expanded
                    if(row.IsSelfRefRow != null)
                    {
                        if (row.IsSelfRefRow) { // &amp;amp;&amp;amp; SelfRefExpanded
                            row.CollapseSelfRefRow();
                        }
                    }
                }
            }
            else {
                document.getElementById("hid_expand_flag").value = "1";
                ctl.value = "一键折叠"

                grid.Refresh();
            }
            return;
        }&lt;/pre&gt;&lt;p&gt;&amp;nbsp;but only first row collapsed, see attachment file&lt;span style="font-family: 'Courier New', Tahoma; font-size: 9pt; background-color: rgb(255, 252, 225);"&gt;.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: 'Courier New', Tahoma; font-size: 9pt; background-color: rgb(255, 252, 225);"&gt;Regards,&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: 'Courier New', Tahoma; font-size: 9pt; background-color: rgb(255, 252, 225);"&gt;RogerChen&lt;/span&gt;&lt;/p&gt;</description></item><item><title>How to use server code Collapse WebGrid (SelfReferencing)</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-to-use-server-code-Collapse-WebGrid-SelfReferencing/</link><pubDate>Mon, 03 Nov 2014 08:57:43 GMT</pubDate><dc:creator>Hans</dc:creator><category>WebGrid</category><category>Collapse</category><description>&lt;p&gt;Hello,&lt;br&gt;&lt;br&gt;Thank you for the question regarding WebGrid.&lt;br&gt;&lt;br&gt;Basically, WebGrid doesn’t provide method to collapse the Self Reference WebGrid from server side.&lt;br&gt;However, WebGrid has provided a method to expand &amp;amp; collapse the Self Reference WebGrid from client side.&lt;br&gt;There is a method to expand the Self Reference WebGrid from server side.&lt;br&gt;&lt;br&gt;To show you how to implement those method, I tried to modify one of WebGrid Samples, SelfReferencingGrid.aspx page. &lt;br&gt;In this modified sample/page, I will expand and collapse the first row. I added a couple of buttons to implement those method.&lt;br&gt;&lt;br&gt;Here’s the snippet code about expand row from client side:&lt;br&gt;&lt;/p&gt;&lt;pre&gt;function Button1_Click(){
    var WebGrid1 = ISGetObject("WebGrid1");
    var row = WebGrid1.RootTable.GetRowByKeyValue("2");
    row.ExpandSelfRefRow();
    return true;
}&lt;/pre&gt;&lt;p&gt;Here’s the snippet code about collapse row from client side:&lt;br&gt;&lt;/p&gt;&lt;pre&gt;function Button2_Click()
{
    var WebGrid1 = ISGetObject("WebGrid1");
    var row = WebGrid1.RootTable.GetRowByKeyValue("2");
    row.CollapseSelfRefRow();
    return true;
}&lt;/pre&gt;&lt;p&gt;Here’s the snippet code about expand row from server side:&lt;br&gt;&lt;/p&gt;&lt;pre&gt;protected void Button3_Click(object sender, EventArgs e)
{
    WebGrid1.RootTable.Rows.GetRowByKeyValue("2").ExpandSelfRefRow();
}&lt;/pre&gt;&lt;p&gt;I attached the modified sample as well, so that you can have review on the sample. You just simply add the sample to the WebGrid Samples Solution.&lt;br&gt;&lt;br&gt;In this sample, by default, the row state of the Self Reference WebGrid is Collapse. The expanded row will be collapse after post back. So I don’t need the collapse method in server side to collapse the row.&lt;br&gt;&lt;br&gt;If you don’t mind, could you inform me more information regarding your current scenario? So that I can help you to find the suitable solution for your current scenario.&lt;br&gt;&lt;br&gt;Hope this helps.&lt;br&gt;&lt;br&gt;Regards,&lt;br&gt;Hans K.&lt;br&gt;&lt;/p&gt;</description></item><item><title>How to use server code Collapse WebGrid (SelfReferencing)</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-to-use-server-code-Collapse-WebGrid-SelfReferencing/</link><pubDate>Fri, 31 Oct 2014 08:40:09 GMT</pubDate><dc:creator>rogerchen.tangshuo@gmail.com</dc:creator><category>WebGrid</category><category>Collapse</category><description>&lt;p&gt;I has a webgrid in page, first loaded this page, webgrid show tree data(set SelfReferencingSettings property),i want to collapse all row by button. how can i coding? &lt;/p&gt;&lt;p&gt;thanks&lt;br&gt;&lt;/p&gt;</description></item></channel></rss>