Ejemplo n.º 1
0
        public IHtmlNode CreateBody(GridRenderingData renderingData)
        {
            var enumerator = new GridDataSourceEnumerator(renderingData.DataSource, itemCreatorFactory.Create(renderingData.DataKeyStore, renderingData), renderingData.InsertRowPosition);

            var rowBuilders = enumerator.Select(item => rowBuilderFactory.CreateBuilder(renderingData, item));

            return(CreateBody(rowBuilders));
        }
Ejemplo n.º 2
0
        public IEnumerator <GridItem> GetEnumerator()
        {
            int counter = 0;

            var insertItem = creator.CreateInsertItem();

            if (insertItem != null && groupLevel == 0 && insertRowPosition != GridInsertRowPosition.Bottom)
            {
                counter++;
                yield return(insertItem);
            }

            if (dataSource != null)
            {
                foreach (var dataItem in dataSource)
                {
                    var result = creator.CreateItem(dataItem);
                    result.GroupLevel = groupLevel;
                    result.Index      = counter++;

                    result.AsAlternating();

                    yield return(result);

                    if (result.Type == GridItemType.GroupRow)
                    {
                        var group      = dataItem as IGroup;
                        var enumerator = new GridDataSourceEnumerator(group.Items, creator, groupLevel + 1);

                        foreach (var item in enumerator)
                        {
                            yield return(item);
                        }

                        var groupFooter = creator.CreateGroupFooterItem(group);
                        if (groupFooter != null)
                        {
                            groupFooter.Index = counter++;
                            yield return(groupFooter);
                        }
                    }
                    else if ((result.State & GridItemStates.Master) == GridItemStates.Master)
                    {
                        yield return(new GridDetailViewItem
                        {
                            DataItem = dataItem,
                            GroupLevel = result.GroupLevel,
                            Type = GridItemType.DetailRow,
                            Parent = result
                        });
                    }
                }
            }

            if (insertItem != null && groupLevel == 0 && insertRowPosition == GridInsertRowPosition.Bottom)
            {
                counter++;
                yield return(insertItem);
            }

            if (counter == 0)
            {
                yield return(new GridItem
                {
                    Type = GridItemType.EmptyRow
                });
            }
        }