views:

1885

answers:

1

I am using a RadGrid (2009 Q2) with a hierarchy. Is there a way in the client api to expand all rows and vice-versa?

thanks!

Update: I have written a javascript function based off the api documentation suggested by Dick Lampard below to expand/collapse all rows in a radgrid with three levels. It expands all the mastertableview rows and all the nested detailtableview rows in both sub levels of the first mastertableview row, but it breaks when it goes the to detailtableview rows for the second mastertableview row (whew!). The error I am getting is "_350 is undefined". This is coming from a Telerik.Web.UI.WebResource file.

function ExpandCollapseAll(expand) {
    var grid = $find("<%= rgHistory.ClientID %>");

    master = grid.get_masterTableView();
    var masterRowCount = master.get_dataItems().length;

    for (masterIndex = 0; masterIndex < masterRowCount; masterIndex++) {
        if (expand) {
            master.expandItem(masterIndex);
        }
        else {
            master.collapseItem(masterIndex);
        }
    } 

    var detailTables = grid.get_detailTables();
    var detailTableCount = detailTables.length;

    for (detailTableIndex = 0; detailTableIndex < detailTableCount; detailTableIndex++) {
        var detailTable = detailTables[detailTableIndex];
        var rowCount = detailTable.get_dataItems().length;
        for (rowIndex = 0; rowIndex < rowCount; rowIndex++) {
            if (expand) {
                //expandItem is failing!  detailTableIndex and rowIndex are correct
                detailTables[detailTableIndex].expandItem(rowIndex);
            }
            else {
                detailTables[detailTableIndex].collapseItem(rowIndex);
            }
        }
    }            
}

ANY IDEAS?!?!

+1  A: 

There is client API for hierarchy expansion as well as ExpandHierarchyToTop() server method. Check out this demo.

Dick

related questions