Rows in unbound hierarchic grid do not set Expand property when expanded

2 replies. Last post: May 4, 2011 10:25 AM by Robert Pehrson
Tags :
  • (None)

I have an unbound hierarchic grid where the user can expand and collapse the top level rows, and I need to be able to rebuild it on postback with the same rows expanded.  I tried using the Expand property of rows before the postback, but it is never set true.  I also tried handling the OnGroupExpand event, but this does not seem to fire.

To demonstrate these problems, I've added to the Hierarchical_Unbound_Programmatic tutorial.  On the apsx, I added

<script type="text/javascript">
    function OnClientCellDblClick(id,args) {
        var grid = ISGetObject(id);
        var rt = grid.RootTable;
        var rc = rt.GetRowsCount();
        var noneExpanded = true;
        for (i = 0; i < rc; i++) {
            var r = rt.GetRow(i);
            if (r.Expanded) {
                alert('Row ' + i + ' is expanded');
                noneExpanded = false;
            }
        }
        if (noneExpanded) alert('No rows are expanded');
    }

    function OnClientGroupExpand(id) {
        alert('group expanded');
    }
</script>

and in the code behind, I added to the Page_Load method

        grid.LayoutSettings.ClientSideEvents.OnCellDblClick = "OnClientCellDblClick";
        grid.LayoutSettings.ClientSideEvents.OnGroupExpand = "OnClientGroupExpand";

If you run the page and expand a line, the OnGroupExpand does not fire.  If you then double click on any cell, the OnClientCellDblClick function will not find any rows expanded. 

Answers

Hello Robert,

To get a rows that expanded by user, I think you get little bit missing. you should use ChildExpanded. You can try this code :


<script type="text/javascript">
        function OnClientCellDblClick(id, args) {
            var grid = ISGetObject(id);
            var rt = grid.RootTable;
            var rc = rt.GetRowsCount();
            var noneExpanded = true;
            for (i = 0; i < rc; i++) {
                var r = rt.GetRow(i);
                
                if (r.ChildExpanded == true) {
                    alert('Row ' + i + ' is expanded');
                    noneExpanded = false;
                }
            }
            if (noneExpanded==true) alert('No rows are expanded');
        }
        function OnClientGroupExpand(id) {
            alert('group expanded');
        }

 

 Would you like to tell me that I am right or not ?


Hope this helps.

Riendy

All Replies

Hello Robert,

To get a rows that expanded by user, I think you get little bit missing. you should use ChildExpanded. You can try this code :


<script type="text/javascript">
        function OnClientCellDblClick(id, args) {
            var grid = ISGetObject(id);
            var rt = grid.RootTable;
            var rc = rt.GetRowsCount();
            var noneExpanded = true;
            for (i = 0; i < rc; i++) {
                var r = rt.GetRow(i);
                
                if (r.ChildExpanded == true) {
                    alert('Row ' + i + ' is expanded');
                    noneExpanded = false;
                }
            }
            if (noneExpanded==true) alert('No rows are expanded');
        }
        function OnClientGroupExpand(id) {
            alert('group expanded');
        }

 

 Would you like to tell me that I am right or not ?


Hope this helps.

Riendy

You're right, Riendy, it's the ChildExpanded property that I need - it works fine.  The help could be clearer about this; as I understand "expanded", child rows are shown when the parent is expanded and not when the parent is collapsed. So for the Expanded property "Gets or sets a value that indicates whether the row is expanded" should read "... whether the row's parent is expanded".  The ChildExpanded text is "Determines whether the Child Rows of current row is expanded" should read "... whether this row is expanded". 

Anyway, thanks for your help. 

All times are GMT -5. The time now is 9:47 PM.
Previous Next