Example #1
0
 private IEnumerable <Func <EwfTableItem> > getItems(int count, bool includeId)
 {
     return(from i in Enumerable.Range(1, count)
            select new Func <EwfTableItem>(
                () => EwfTableItem.Create(
                    EwfTableItemSetup.Create(
                        activationBehavior: ElementActivationBehavior.CreateRedirectScript(ActionControls.GetInfo()),
                        id: includeId ? new SpecifiedValue <int>(i) : null),
                    i.ToString().ToCell(),
                    ((i * 2) + Environment.NewLine + "extra stuff").ToCell())));
 }
 protected override void loadData()
 {
     ph.AddControlsReturnThis(
         EwfTable
         .Create(
             tableActions: new HyperlinkSetup(new EditUser.Info(es.info, null), "Create User").ToCollection(),
             headItems: EwfTableItem.Create("Email".ToCell().Append("Role".ToCell()).Materialize()).ToCollection())
         .AddData(
             UserManagementStatics.GetUsers(),
             user => EwfTableItem.Create(
                 user.Email.ToCell().Append(user.Role.Name.ToCell()).Materialize(),
                 setup: EwfTableItemSetup.Create(
                     activationBehavior: ElementActivationBehavior.CreateRedirectScript(new EditUser.Info(es.info, user.UserId)))))
         .ToCollection()
         .GetControls());
 }
        protected override void loadData()
        {
            var itemGroups = Enumerable.Range(1, 2)
                             .Select(
                group => ColumnPrimaryItemGroup.Create(
                    "Group {0}".FormatWith(group).ToComponents(),
                    groupActions:
                    new ButtonSetup(
                        "Action 1",
                        behavior: new PostBackBehavior(
                            postBack: PostBack.CreateIntermediate(
                                null,
                                id: PostBack.GetCompositeId(group.ToString(), "action1"),
                                firstModificationMethod: () => AddStatusMessage(StatusMessageType.Info, "Action 1")))).Append(
                        new ButtonSetup(
                            "Action 2",
                            behavior: new PostBackBehavior(
                                postBack: PostBack.CreateIntermediate(
                                    null,
                                    id: PostBack.GetCompositeId(group.ToString(), "action2"),
                                    firstModificationMethod: () => AddStatusMessage(StatusMessageType.Info, "Action 2")))))
                    .Materialize(),
                    selectedItemActions: group == 1
                                                                             ? SelectedItemAction.CreateWithIntermediatePostBackBehavior <int>(
                        "Echo group IDs",
                        null,
                        ids => AddStatusMessage(
                            StatusMessageType.Info,
                            StringTools.GetEnglishListPhrase(ids.Select(i => i.ToString()), true)))
                    .ToCollection()
                                                                             : Enumerable.Empty <SelectedItemAction <int> >().Materialize(),
                    items: Enumerable.Range(1, 5)
                    .Select(
                        i => EwfTableItem.Create(
                            EwfTableItemSetup.Create(
                                activationBehavior: ElementActivationBehavior.CreateRedirectScript(ActionControls.GetInfo()),
                                id: new SpecifiedValue <int>(group * 10 + i)),
                            i.ToString().ToCell(),
                            ((i * 2) + Environment.NewLine + "extra stuff").ToCell()))))
                             .Materialize();

            place.AddControlsReturnThis(
                ColumnPrimaryTable.Create(
                    caption: "My table",
                    subCaption: "A new table implementation",
                    allowExportToExcel: true,
                    tableActions: new ButtonSetup(
                        "Action",
                        behavior: new PostBackBehavior(
                            postBack: PostBack.CreateIntermediate(
                                null,
                                id: "action",
                                firstModificationMethod: () => AddStatusMessage(StatusMessageType.Info, "You clicked action.")))).ToCollection(),
                    selectedItemActions: SelectedItemAction
                    .CreateWithIntermediatePostBackBehavior <int>(
                        "Echo IDs",
                        null,
                        ids => AddStatusMessage(StatusMessageType.Info, StringTools.GetEnglishListPhrase(ids.Select(i => i.ToString()), true)))
                    .Append(
                        SelectedItemAction.CreateWithIntermediatePostBackBehavior <int>(
                            "With confirmation",
                            null,
                            ids => AddStatusMessage(StatusMessageType.Info, StringTools.GetEnglishListPhrase(ids.Select(i => i.ToString()), true)),
                            confirmationDialogContent: "Are you sure?".ToComponents()))
                    .Materialize(),
                    fields: new[] { new EwfTableField(size: 1.ToPercentage()), new EwfTableField(size: 2.ToPercentage()) })
                .AddItemGroups(itemGroups)
                .ToCollection()
                .GetControls());
        }
Example #4
0
        public void RealWorldDataTableTest()
        {
            // This is what a dynamic table would output, a list of rowsetups.
            var rowSetups = new List <RowSetup>();

            rowSetups.Add(
                new RowSetup
            {
                IsHeader = true,
                CsvLine  = new List <string>
                {
                    "Name",
                    "Company",
                    "Location",
                    "Url",
                    "Phone"
                }
            });

            var names     = new[] { "Sofeee", "Cathie", "Ann", "Jan", "Patty", "Cora" };
            var surNames  = new[] { "Norjaim", "Carbelt", "Wilson", "Middleberger", "Hewlett", "Taylor", "Danzen" };
            var companies = new[] { "Synergy", "Enterprises", "Dancing", "Buzz", "Local", "of Rochester" };
            var streets   = new[] { "Broad Rd", "W Elm St", "Main", "James Ave", "Water Blvd", "West Way" };

            for (var i = 0; i < 72; i++)
            {
                rowSetups.Add(
                    new RowSetup
                {
                    CsvLine = new List <string>
                    {
                        // Some random-looking values
                        names[i % names.Count()] + " " + surNames[i % surNames.Count()],
                        companies[(i + (i / 2)) % companies.Count()] + " " + companies[i % companies.Count()],
                        i + " " + streets[i % streets.Count()],
                        "http://www.google.com/search?q=" + i,
                        i.ToString("D3") + "-867-5309"
                    },
                    ActivationBehavior = ElementActivationBehavior.CreateRedirectScript(new ExternalResourceInfo("http://google.com")),
                    CssClass           = "gibberish_string_for_testing",
                    IsHeader           = false,
                    RankId             = i,
                    UniqueIdentifier   = "row" + i
                });
            }

            runTest(
                writer => {
                foreach (var rowSetup in rowSetups)
                {
                    if (rowSetup.IsHeader)
                    {
                        writer.DefaultWorksheet.AddHeaderToWorksheet(rowSetup.CsvLine.ToArray());
                    }
                    else
                    {
                        writer.DefaultWorksheet.AddRowToWorksheet(rowSetup.CsvLine.ToArray());
                    }
                }
                return("data_table");
            });
        }