Exemplo n.º 1
0
        private GridRenderingData CreateRenderingData()
        {
            var renderingData = new GridRenderingData
            {
                TableHtmlAttributes = TableHtmlAttributes,
                DataKeyStore        = DataKeyStore,
                HtmlHelper          = new GridHtmlHelper <T>(ViewContext, DataKeyStore),
                UrlBuilder          = UrlBuilder,
                DataSource          = DataProcessor.ProcessedDataSource,
                Columns             = VisibleColumns.Cast <IGridColumn>(),
                GroupMembers        = DataProcessor.GroupDescriptors.Select(g => g.Member),
                Mode                   = CurrentItemMode,
                EditMode               = Editing.Mode,
                HasDetailView          = HasDetailView,
                Colspan                = Colspan - Columns.Count(column => column.Hidden),
                DetailViewTemplate     = MapDetailViewTemplate(HasDetailView ? DetailView.Template : null),
                NoRecordsTemplate      = FormatNoRecordsTemplate(),
                Localization           = Localization,
                ScrollingHeight        = Scrolling.Height,
                EditFormHtmlAttributes = Editing.FormHtmlAttributes,
                ShowFooter             = Footer && VisibleColumns.Any(c => c.FooterTemplate.HasValue() || c.ClientFooterTemplate.HasValue()),
                AggregateResults       = DataProcessor.AggregatesResults,
                Aggregates             = Aggregates.SelectMany(aggregate => aggregate.Aggregates),
                GroupsCount            = DataProcessor.GroupDescriptors.Count,
                ShowGroupFooter        = Aggregates.Any() && VisibleColumns.OfType <IGridBoundColumn>().Any(c => c.GroupFooterTemplate.HasValue()),
                PopUpContainer         = new HtmlFragment(),
#if MVC2 || MVC3
                CreateNewDataItem  = () => Editing.DefaultDataItem(),
                InsertRowPosition  = Editing.InsertRowPosition,
                EditTemplateName   = Editing.TemplateName,
                AdditionalViewData = Editing.AdditionalViewData,
                FormId             = ViewContext.FormContext.FormId,
#endif
                Callback = RowActionCallback
            };

            if (RowTemplate.HasValue())
            {
                renderingData.RowTemplate = (dataItem, container) => RowTemplate.Apply((T)dataItem, container);
            }

            return(renderingData);
        }