Inheritance: IXafCallbackHandler, IProcessCallbackComplete
        public void InnerRender()
        {
            if (Handler == null)
            {
                Handler             = new CallbackHandler(ClientID + "_handler");
                Handler.OnCallback += Handler_OnCallback;
            }

            Content.Controls.Clear();
            InnerLoadControlState();

            #region Read headers info

            //Make headers
            HeaderColumns = new List <HeaderInfo>();

            //Counter column
            if (ShowNumbers)
            {
                HeaderColumns.Add(new HeaderInfo()
                {
                    FixedWidth = 20, Align = "right", Caption = "#", FieldName = "SystemColumn_RowCounter", ID = "SystemColumn_RowCounter", Index = 0
                });
            }

            foreach (var item in CustomColumns)
            {
                HeaderColumns.Add(item);
            }

            int ColumnIdx = 0;
            if (ListView != null)
            {
                foreach (var column in ListView.Columns)
                {
                    var columnIsVisible = true;
                    #region CALCULATE ELEMENT APPEARANCE
                    if (ObjectTypeInfo != null && ObjectSpace != null)
                    {
                        var member = ObjectTypeInfo.FindMember(column.Id);
                        if (member != null)
                        {
                            foreach (var appearanceItem in member.FindAttributes <AppearanceAttribute>().Where(f => (String.Concat(f.Context) == "" || String.Concat(f.Context) == "Any" || f.Context.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()).ToList().IndexOf("ListView") > -1)))
                            {
                                if (Convert.ToBoolean(ObjectSpace.GetExpressionEvaluator(ObjectTypeInfo.Type, CriteriaOperator.Parse(appearanceItem.Criteria)).Evaluate(null)))
                                {
                                    switch (appearanceItem.Visibility)
                                    {
                                    case ViewItemVisibility.ShowEmptySpace:
                                    case ViewItemVisibility.Hide:
                                        columnIsVisible = false;
                                        break;

                                    case ViewItemVisibility.Show:
                                        columnIsVisible = true;
                                        break;
                                    }
                                }
                            }
                        }

                        foreach (var appearanceItem in ObjectTypeInfo.FindAttributes <AppearanceAttribute>().Where(f => String.Concat(f.TargetItems).Split(',').Where(s => s.Trim() == column.Id).Count() > 0 && (String.Concat(f.Context) == "" || String.Concat(f.Context) == "Any" || f.Context.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()).ToList().IndexOf("ListView") > -1)))
                        {
                            if (Convert.ToBoolean(ObjectSpace.GetExpressionEvaluator(ObjectTypeInfo.Type, CriteriaOperator.Parse(appearanceItem.Criteria)).Evaluate(null)))
                            {
                                switch (appearanceItem.Visibility)
                                {
                                case ViewItemVisibility.ShowEmptySpace:
                                case ViewItemVisibility.Hide:
                                    columnIsVisible = false;
                                    break;

                                case ViewItemVisibility.Show:
                                    columnIsVisible = true;
                                    break;
                                }
                            }
                        }
                    }
                    #endregion

                    if ((column.Index == null || column.Index > -1) && columnIsVisible)
                    {
                        var align = "left";
                        if (ObjectTypeInfo != null)
                        {
                            var member = ObjectTypeInfo.FindMember(column.GetValue <String>("FieldName"));
                            switch (Type.GetTypeCode(member.MemberType))
                            {
                            case TypeCode.Boolean:
                            case TypeCode.Decimal:
                            case TypeCode.Int16:
                            case TypeCode.Int32:
                            case TypeCode.Int64:
                            case TypeCode.UInt16:
                            case TypeCode.UInt32:
                            case TypeCode.UInt64:
                            case TypeCode.Double:
                                align = "right";
                                break;

                            default:
                                align = "left";
                                break;
                            }
                        }

                        HeaderColumns.Add(new HeaderInfo()
                        {
                            Index = ColumnIdx, Caption = column.Caption, FieldName = column.GetValue <String>("FieldName"), ID = column.Id, Align = align, Model = column, MinWidth = column.Width
                        });
                        ColumnIdx++;
                    }
                }
            }

            #region read form values

            foreach (var column in HeaderColumns.Where(f => f.Model != null))
            {
                var sorting        = String.Concat(Request.Form[ClientID + "_sort_" + column.FieldName]);
                var sortingOptions = sorting.Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                if (sortingOptions.Length > 0)
                {
                    column.Sorting = (SortDirection)(sortingOptions[0] == "1" ? 1 : sortingOptions[0] == "2" ? 2 : 0);
                    if (sortingOptions.Length > 1)
                    {
                        column.SortIndex = double.Parse(sortingOptions[1]);
                    }
                }
                column.Filter = Request.Form[ClientID + "_filter_" + column.FieldName];
            }

            #endregion

            #endregion

            AddStringContent("<div>");

            #region FilterButton

            if (ShowHeaders)
            {
                if (ShowFilter)
                {
                    AddStringContent(String.Format(@"<div class=""table-filter-button {0}"" onclick=""if ($(this).hasClass('btn-default')) {{ $(this).removeClass('btn-default').addClass('btn-primary'); }} else {{ $(this).addClass('btn-default').removeClass('btn-primary'); }}; $(this).parent().find('.filter-row').first().toggle();""><span class=""glyphicon glyphicon-filter""></span></div>"
                                                   , (HeaderColumns.Count(f => String.Concat(f.Filter) != "") > 0 ? "btn-primary" : "btn-default")));
                }
            }

            #endregion

            AddStringContent("<div class='table-responsive panel panel-default'>");

            AddStringContent(String.Format(@"<table class='table {1} {2} xaf-bootstrap' id = '{0}_Table'>"
                                           , ClientID
                                           , TableHover ? "table-hover" : ""
                                           , TableStriped ? "table-striped" : ""));

            StringBuilder TableScripts = new StringBuilder();

            int         ItemsCount = 0;
            IMemberInfo memberInfo;

            #region Build Header Row, Filters

            if (ShowHeaders)
            {
                AddStringContent("<thead>");
                AddStringContent("<tr>");

                foreach (var column in HeaderColumns.OrderBy(f => f.Index))
                {
                    String columnVal    = column.Caption;
                    String columnFormat = String.Format(@"<th {{1}} {{4}} style=""text-align: {{2}}; {0} {1} {2}"">{{0}} {{3}}<input type=""hidden"" name=""{3}_sort_{4}"" value=""{5}""></th>"
                                                        , column.MaxWidth > -1 ? String.Format("max-width: {0}px;", column.MaxWidth) : ""
                                                        , column.MinWidth > -1 ? String.Format("min-width: {0}px;", column.MinWidth) : ""
                                                        , column.FixedWidth > -1 ? String.Format("width: {0}px;", column.FixedWidth) : ""
                                                        , ClientID
                                                        , column.FieldName
                                                        , (int)column.Sorting
                                                        );
                    if (OnGenerateHeader != null)
                    {
                        OnGenerateHeader(ref columnFormat, column.FieldName, ref columnVal, null);
                    }

                    String sort      = "";
                    String sortClick = "";
                    if (column.Model != null)
                    {
                        switch (column.Sorting)
                        {
                        case SortDirection.Ascending:
                            sort = @"<span class=""glyphicon glyphicon-chevron-up""></span>";
                            break;

                        case SortDirection.Descending:
                            sort = @"<span class=""glyphicon glyphicon-chevron-down""></span>";
                            break;
                        }

                        sortClick = String.Format(@"onclick=""{1}_DoSort(this)""", column.FieldName, ClientID);
                    }

                    AddStringContent(
                        String.Format(columnFormat
                                      , columnVal
                                      , (column.Model != null && column.Model.ImageEditorFixedHeight > 0) ? String.Format("width={0}", column.Model.ImageEditorFixedHeight) : ""
                                      , column.Align
                                      , sort
                                      , sortClick));
                }

                AddStringContent("</tr>");

                if (ShowFilter)
                {
                    AddStringContent(String.Format(@"<tr class=""filter-row"" style=""{0}"">", HeaderColumns.Count(f => String.Concat(f.Filter) != "") == 0 ? "display: none" : ""));

                    foreach (var column in HeaderColumns.OrderBy(f => f.Index))
                    {
                        AddStringContent(@"<td class=""filter-header"">");
                        if (column.Model != null)
                        {
                            AddStringContent(String.Format(@"<input name=""{0}_filter_{1}"" type=""text"" class=""form-control input-sm"" onkeypress=""{0}_DoFilter(this, event)"" onchange=""{0}_DoFilter(this)"" value=""{2}"">", ClientID, column.FieldName, column.Filter));
                        }
                        AddStringContent("</td>");
                    }

                    AddStringContent("</tr>");
                }

                AddStringContent("</thead>");
            }
            #endregion

            #region Build Data Rows
            IList <Object> objects = null;
            //Make data
            if (DataSource != null)
            {
                int RowCounter = PageIndex * PageItemsCount;
                AddStringContent("<tbody>");

                if (DataSource is IList)
                {
                    objects = (DataSource as IList).OfType <Object>().ToList();

                    //Apply filter
                    foreach (var column in HeaderColumns.Where(f => String.Concat(f.Filter) != ""))
                    {
                        objects = objects.Where(f => IsObjectFiltered(column, column.Filter, f, RowCounter)).ToList();
                    }

                    //Apply sorting
                    int sortCounter = 0;
                    var sortings    = HeaderColumns.Where(f => f.Sorting != SortDirection.None);
                    IOrderedEnumerable <object> orderedList = null;
                    foreach (var column in sortings.OrderBy(f => f.SortIndex))
                    {
                        switch (column.Sorting)
                        {
                        case SortDirection.Ascending:
                            if (sortCounter == 0)
                            {
                                orderedList = objects.OrderBy(f => ObjectFormatValues.GetValueRecursive(column.FieldName, f, out memberInfo));
                            }
                            else
                            {
                                orderedList = orderedList.ThenBy(f => ObjectFormatValues.GetValueRecursive(column.FieldName, f, out memberInfo));
                            }
                            break;

                        case SortDirection.Descending:
                            if (sortCounter == 0)
                            {
                                orderedList = objects.OrderByDescending(f => ObjectFormatValues.GetValueRecursive(column.FieldName, f, out memberInfo));
                            }
                            else
                            {
                                orderedList = orderedList.ThenByDescending(f => ObjectFormatValues.GetValueRecursive(column.FieldName, f, out memberInfo));
                            }
                            break;
                        }
                        sortCounter++;
                    }
                    if (orderedList != null)
                    {
                        objects = orderedList.ToList();
                    }

                    ItemsCount = objects.Count;

                    PagesCount = (int)Math.Ceiling(((float)objects.Count / PageItemsCount));

                    if (PagesCount - 1 < PageIndex)
                    {
                        PageIndex = Math.Max(PagesCount - 1, 0);
                    }

                    foreach (var item in objects.Skip(PageIndex * PageItemsCount).Take(PageItemsCount))
                    {
                        StringBuilder row = new StringBuilder();
                        switch (SelectionType)
                        {
                        case SelectionObjectType.SingleObject:
                            if (OnGenerateItemClick == null)
                            {
                                row.AppendFormat(String.Format("<tr onclick=\"{0}\">", Handler.GetScript(String.Format("'SelectedObject|{0}'", RowCounter))));
                            }
                            else
                            {
                                String Click = "<tr onclick=\"{0}\">";
                                OnGenerateItemClick(ref Click, RowCounter, item);
                                row.AppendFormat(String.Format(Click, Handler.GetScript(String.Format("'SelectedObject|{0}'", RowCounter))));
                            }
                            break;

                        case SelectionObjectType.MultipleObject:
                        default:
                            if (OnGenerateItemClick == null)
                            {
                                row.AppendFormat(String.Format("<tr onclick=\"{0}\">", Handler.GetScript(String.Format("'BrowseObject|{0}'", RowCounter))));
                            }
                            else
                            {
                                String Click = "<tr onclick=\"{0}\">";
                                OnGenerateItemClick(ref Click, RowCounter, item);
                                row.AppendFormat(String.Format(Click, Handler.GetScript(String.Format("'BrowseObject|{0}'", RowCounter))));
                            }
                            break;
                        }

                        foreach (var column in HeaderColumns.OrderBy(f => f.Index))
                        {
                            String FieldName = (column.Model != null ? column.Model.PropertyName : column.FieldName);

                            var objValue = ObjectFormatValues.GetValueRecursive(FieldName, item, out memberInfo);

                            String Value = FormatValue(memberInfo, objValue, column.Model, RowCounter);

                            if (column.FieldName == "SystemColumn_RowCounter")
                            {
                                Value = String.Format("{0}", RowCounter);
                            }

                            String DataFormat = "<td style=\"text-align: {1}\">{0}</td>";

                            if (OnGenerateCell != null)
                            {
                                OnGenerateCell(ref DataFormat, column.ID, ref Value, RowCounter, item);
                            }

                            row.AppendFormat(String.Format(DataFormat, String.Concat(Value).Replace("{", "{{").Replace("}", "}}"), column.Align));
                        }

                        row.AppendFormat("</tr>");
                        var     RowString = row.ToString();
                        Control Control   = null;

                        if (OnGenerateRowFinished != null)
                        {
                            OnGenerateRowFinished(ref RowString, ref Control, RowCounter, item);
                        }

                        AddStringContent(RowString);
                        if (Control != null)
                        {
                            AddContent(Control);
                        }

                        RowCounter++;
                    }
                }

                AddStringContent("</tbody>");
            }
            #endregion

            #region Build Footers

            if (ListView != null)
            {
                var SummaryColumns = ListView.Columns.Where(f => f.Summary.Count > 0).ToList();
                var HasFooters     = SummaryColumns.Count > 0;
                IList <SummaryValue> SummaryValues = new List <SummaryValue>();
                foreach (var col in SummaryColumns)
                {
                    SummaryValues.Add(new SummaryValue()
                    {
                        Column = col
                    });
                }

                AddStringContent("<tfoot>");
                int colSpan = 0;
                if (HasFooters && objects != null)
                {
                    foreach (var item in objects)
                    {
                        foreach (var summary in SummaryValues)
                        {
                            decimal summaryValue = 0;
                            if (decimal.TryParse(String.Concat(ObjectFormatValues.GetValueRecursive(summary.Column.FieldName, item, out memberInfo)), out summaryValue))
                            {
                                summary.AddValue(summaryValue);
                            }
                        }
                    }

                    AddStringContent("<tr>");
                    foreach (var column in HeaderColumns.OrderBy(f => f.Index))
                    {
                        var summary = SummaryValues.Where(f => f.Column == column.Model).FirstOrDefault();
                        if (summary != null)
                        {
                            if (colSpan > 0)
                            {
                                AddStringContent(String.Format("<td colspan=\"{0}\"></td>", colSpan));
                            }

                            AddStringContent(String.Format("<td class=\"text-right\">{0:n}</td>", summary.Summary));
                            colSpan = 0;
                        }
                        else
                        {
                            colSpan++;
                        }
                    }
                    if (colSpan > 0)
                    {
                        AddStringContent(String.Format("<td colspan=\"{0}\"></td>", colSpan));
                    }
                    AddStringContent("</tr>");
                }
                AddStringContent("</tfoot>");
            }
            #endregion

            AddStringContent("</table>");
            AddStringContent("</div>");

            AddStringContent("</div>");

            #region Build Pager
            //Pager
            if (PagesCount > 1)
            {
                #region Pages
                AddStringContent("<div class='btn-group'>");

                int ButtonsCount = PagerButtonsCount - 2; //Minus two buttons - prev and next
                int FirstHalf    = (int)Math.Ceiling((decimal)ButtonsCount / 2);

                if (ID == null || String.Concat(ID).IndexOf(Helpers.JoinString) > -1)
                {
                    if (Parent != null)
                    {
                        ID = Parent.ID = Helpers.JoinString + "table";
                    }
                    else
                    {
                        ID = Guid.NewGuid().ToString();
                    }
                }

                AddStringContent(String.Format("<button type=\"button\" class=\"btn btn-default btn-sm\" onclick=\"{0}\">&laquo;</button>", Handler.GetScript("'PageIndex|-'")));

                int aStartIdx  = Math.Min(Math.Max(0, PageIndex - FirstHalf), PagesCount - ButtonsCount - 1);
                int aFinishIdx = aStartIdx + ButtonsCount - ((aStartIdx > 0) ? 1 : 0);

                for (int i = 1; i <= PagesCount; i++)
                {
                    if ((i >= aStartIdx + 1 && i <= aFinishIdx + 1) || i == 1 || i == PagesCount)
                    {
                        AddStringContent(String.Format("<button type=\"button\" class=\"btn btn-default btn-sm {2}\" onclick=\"{1}\">{0}</button>", i, Handler.GetScript(String.Format("'PageIndex|{0}'", i)), (i == (PageIndex + 1)) ? @"active" : ""));
                    }
                }
                AddStringContent(String.Format("<button type=\"button\" class=\"btn btn-default btn-sm\" onclick=\"{0}\">&raquo;</button>", Handler.GetScript("'PageIndex|+'")));
                AddStringContent("</div>");

                #endregion

                #region GOTO Page
                ///Modal GOTO Page
                AddStringContent("<div class='btn-group'>");
                AddStringContent(String.Format("<button type=\"button\" class=\"btn btn-default btn-sm\" data-toggle=\"modal\" data-target=\"#{0}_GotoPageindex\">{1}</button>", ClientID, Helpers.GetLocalizedText(@"XAF Bootstrap\Controls\XafBootstrapTable", "GotoPage")));
                AddStringContent("</div>");

                String aGoto = String.Format(@"
                <!-- Modal -->          
                <div class='modal fade' id='{0}_GotoPageindex' tabindex='-1' style='display: none;' data-focus-on='input:first'>                      
                    <div class='modal-dialog modal-lg'>
                        <div class='modal-content'>
                            <div class='modal-header'>
                                <button type='button' class='close' data-dismiss='modal'><span aria-hidden='true'>&times;</span><span class='sr-only'>Закрыть</span></button>
                                <h4 class='modal-title' id='{0}_GotoPageindexLabel'>{2}</h4>
                            </div>
                            <div class='modal-body'>
                                <div class='input-group'>
                                    <span class='input-group-addon'>#</span>
                                    <input id='{0}_GotoPageNumber' type='text' class='form-control' placeholder='{3}'>
                                </div>
                            </div>
                            <div class='modal-footer'>
                                <button type='button' class='btn btn-default btn-sm' data-dismiss='modal'>Отмена</button>
                                <button type='button' class='btn btn-primary btn-sm' data-dismiss='modal' onclick=""{1};"">Перейти</button>
                            </div>                    
                        </div>
                    </div>
                </div>                
                ", ClientID
                                             , Handler.GetScript(String.Format("'PageIndex|' + $('#{0}_GotoPageNumber').val()", ClientID))
                                             , Helpers.GetLocalizedText(@"XAF Bootstrap\Controls\XafBootstrapTable", "DialogGotoPageCaption")
                                             , Helpers.GetLocalizedText(@"XAF Bootstrap\Controls\XafBootstrapTable", "DialogGotoPageEnterPageNumber"));

                AddStringContent(aGoto);

                #endregion
            }
            #endregion

            IsFloatThead = false;
            if (IsFloatThead && (ItemsCount > 1))
            {
                TableScripts.AppendFormat(@"
                    var offset = $('.navbar-fixed-top').height();                
                    $('#{0}_Table').floatThead({{ scrollingTop: offset }});                    
                ", ClientID);
            }

            TableScripts.AppendFormat(@"
                window['{0}_DoFilter'] = function(filterInput, keyPressEvent) {{
                    var refresh = ((!keyPressEvent) || keyPressEvent.which == 13 || keyPressEvent.keyCode == 13);                    
                    if (refresh == true) {{
                        {1};
                    }};                
                }};
                window['{0}_DoSort'] = function(sortProp) {{
                    var values = $(sortProp).find('input').val().split(',');
                    var val = parseInt(values[0], 0) + 1;
                    var timestamp = Date.now();                    
                    if (val > 2)
                        val = 0;
                    else if (values.length > 1)
                        timestamp = values[1];                    
                    
                    $(sortProp).find('input').val(val + ',' + timestamp);
                    {2};
                }};
                
            ", ClientID, Handler.GetScript("'FiltersUpdated|'"), Handler.GetScript("'DoSort|' + sortProp"));

            #region Scripts

            if (TableScripts.Length > 0)
            {
                WebWindow.CurrentRequestWindow.RegisterStartupScript(ClientID + "_scripts", TableScripts.ToString(), true);
            }

            Scripts = new ASPxLabel();
            Scripts.ClientSideEvents.Init  = ClientSideEvents.Init;
            Scripts.ClientSideEvents.Click = ClientSideEvents.Click;

            AddContent(Scripts);

            #endregion
        }
 public virtual void RegisterHandler()
 {
     Handler = new CallbackHandler(control.ClientID);
     Handler.OnCallback += Handler_OnCallback;
 }
 protected override void OnInit(EventArgs e)
 {
     base.OnInit(e);
     handler = new CallbackHandler(ClientID);
     handler.OnCallback += handler_OnCallback;
     DetailViewContent = new Control();
     Controls.Add(DetailViewContent);
     InnerRender();
 }
 protected override void OnInit(EventArgs e)
 {
     base.OnInit(e);
     WebActionContainerHelper.TryRegisterActionContainer(this, ActionContainers);
     if (!DesignMode)
     {
         Callback = new CallbackHandler(UniqueID + "_Callback");
         Callback.OnCallback += Callback_OnCallback;
     }
 }
 public void InitHandler(String HandlerID)
 {
     Handler = new CallbackHandler(HandlerID);
     Handler.OnCallback += Handler_OnCallback;
 }
        private void InitCollector(Boolean isEditing)
        {
            Collector = new CollectorControl();

            CallbackHandler handler = new CallbackHandler("ThemeConfigurationCallbackHandler");
            handler.OnCallback += handler_OnCallback;

            var popup = new HTMLText(String.Format(@"
                <div class=""modal fade"" id=""popupThemeLoader"">
                    <div class=""modal-dialog modal-lg"">
                        <div class=""modal-content"">
                            <div class=""modal-header"">
                                <button type=""button"" class=""close"" data-dismiss=""modal"" aria-label=""Close""><span aria-hidden=""true"">&times;</span></button>
                                <h4 class=""modal-title"">Theme CSS uploading</h4>
                            </div>
                            <div class=""modal-body"">
                                <div class=""form-group"">
                                    <label for=""themeName"">Theme name</label>
                                    <input name=""themeName"" type=""text"" class=""form-control"" id=""themeName"" placeholder=""Name of destination theme folder"">
                                </div>

                                <div class=""form-group"">
                                    <label for=""bootstrapCSS"">Bootstrap CSS</label>
                                    <textarea name=""bootstrapCSS"" class=""form-control"" rows=""20"" id=""bootstrapCSS"" placeholder=""Main Bootstrap CSS content""></textarea>
                                </div>
                            </div>
                            <div class=""modal-footer"">
                                <button type=""button"" class=""btn btn-default pull-right"" data-dismiss=""modal"">Cancel</button>
                                <button type=""button"" class=""btn btn-default pull-right"" data-dismiss=""modal"" onclick="" startProgress(); setTimeout(function() {{ {0} }}, 1000);"">OK</button>
                            </div>
                        </div>
                    </div>
                </div>
            ", handler.GetScript("'save'")));

            var popupButton = new HTMLText(@"<button class=""btn btn-default btn-sm"" type=""button"" onclick=""$('#popupThemeLoader').modal();""><span class=""glyphicon glyphicon-upload""></span> Upload</button>");

            Collector.Controls.Add(Edit);
            if (isEditing)
            {
                Collector.Controls.Add(popup);
                Collector.Controls.Add(popupButton);
            }
        }
 public void InitHandler(String HandlerID)
 {
     Handler             = new CallbackHandler(HandlerID);
     Handler.OnCallback += Handler_OnCallback;
 }
 protected override void OnInit(EventArgs e)
 {
     base.OnInit(e);
     Handler = new CallbackHandler(ClientID);
     Handler.OnCallback += Handler_OnCallback;
     Buttons.InitHandler(ClientID + "_buttons");
     InnerRender();
     Initialized = true;
 }
        public void InitHandler(String HandlerID)
        {
            Handler = new CallbackHandler(HandlerID);
            Handler.OnCallback += Handler_OnCallback;

            Buttons.InitHandler(ClientID + "_buttons");
        }
 protected override void OnInit(EventArgs e)
 {
     base.OnInit(e);
     handler = new CallbackHandler(ClientID);
     handler.OnCallback += Handler_OnCallback;
     BuildData();
 }