protected void grid_BeforeGetCallbackResult(object sender, EventArgs e)
    {
        ASPxGridView g = sender as ASPxGridView;

        for (int i = 0; i < g.VisibleRowCount; i++)
        {
            if (g.IsGroupRow(i) && !g.IsRowExpanded(i) && g.GetRowLevel(i) > 0)
            {
                g.ExpandRow(i, true);
            }
        }
    }
        public static int GetDataRowCount(this ASPxGridView source)
        {
            var smartDataSource = source.DataSource as ISmartDataSourse;

            if (smartDataSource != null)
            {
                return(smartDataSource.Count);
            }


            if (source.IsGrouped())
            {
                var result = 0;

                for (var index = 0; index < source.VisibleRowCount; index++)
                {
                    if (source.IsGroupRow(index))
                    {
                        if (source.IsRowExpanded(index) == false)
                        {
                            var keys = (source.DataBoundProxy).GetChildKeysRecursive(index);

                            result += keys.Cast <object>().Count(x => x != null);
                        }
                    }
                    else
                    {
                        result++;
                    }
                }

                return(result);
            }


            return(source.VisibleRowCount);
        }