Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
650
Styling the PDF Before Export using the UltraWebGridDocumentExporter
posted

Good Day all ,

i have a Challenge here. Let me Explain Clearly. I have an HTML Table that gets Generated based on the Values that comes from a  Database and it looks like this

you can view it with big length here

http://www.vuyiswamaseko.com/BlockGrid.JPG

now as you can see the pink Part has values when you mouse over the black arrows. So this means there are Values under nearth each other and in the WEb its Fine but when it comes to Printing this is not because some other values will be hidden. Now The Data you see here , including the Hidden Data is represented in a normal grid like this

 

http://www.vuyiswamaseko.com/GridFromDB.JPG

This includes the Hidden Data that comes up when you mouse Over. My challenge is that i want to Print a PDF like this

 

but if there are Fields behind, it must put them under neath each other in Blocks of the same Color. I have an Example of other Data. See how it Looks

http://www.vuyiswamaseko.com/Blocks.JPG

As you can see the others are Blocked Well with Colors, now and Purple long Block has Values underneath each other, so i would like to put it as a Blocks below each other with the same Color

and this is a Function that does this Blocks

 public void DisplayActivities()
        {
            try
            {
                grdTimetable.DataBind();            // refresh the list of data in the grid
                // parse the rows in the grid, modifying the cells in the graphic table for each entry

                Label[] lblActv = new Label[grdTimetable.Rows.Count];
                int top, left, height, id, duration;
                int day, sess;
                double hue;
                string colorstr, bordercolor, code, staff, venue, term, staffterm;
                ListItem item = new ListItem();
                int[,] Mailbox = new int[timetable.Rows.Length, timetable.Columns.Length];
                Menu[,] MailboxList = new Menu[timetable.Rows.Length, timetable.Columns.Length];

                List<int> modls = new List<int>();
                for (int i = 0; i < grdTimetable.Rows.Count; i++)
                {
                    if (!(modls.Contains(Convert.ToInt32(grdTimetable.Rows[i].Cells[14].Text))))
                    {
                        modls.Add(Convert.ToInt32(grdTimetable.Rows[i].Cells[14].Text));
                    }
                }

                modls.Sort();

                for (int i = 0; i < grdTimetable.Rows.Count; i++)
                {
                    day = Convert.ToInt32(grdTimetable.Rows[i].Cells[0].Text);
                    sess = Convert.ToInt32(grdTimetable.Rows[i].Cells[1].Text);

                    code = grdTimetable.Rows[i].Cells[2].Text + " " + grdTimetable.Rows[i].Cells[4].Text + " " + grdTimetable.Rows[i].Cells[6].Text + " [" + grdTimetable.Rows[i].Cells[7].Text + "]";
                    staff = grdTimetable.Rows[i].Cells[13].Text;
                    venue = grdTimetable.Rows[i].Cells[11].Text;
                    duration = Convert.ToInt32(grdTimetable.Rows[i].Cells[9].Text);
                    term = grdTimetable.Rows[i].Cells[15].Text;
                    staffterm = grdTimetable.Rows[i].Cells[16].Text;

                    if (staffterm.Trim() == string.Empty)
                    {
                        staffterm = term;
                    }

                    lblActv[i] = new Label();
                    lblActv[i].Text = code + "<BR>" + staff + "<BR>" + venue + "<br>" + term;
                    lblActv[i].ToolTip = code.Trim() + " | " + staff.Trim() + " | " + venue.Trim() + " | " + staffterm.Trim() + "\n";
                    lblActv[i].CssClass = "ActivityBox";

                     //keep track of how many subjects lie in each mailbox
                    for (int j = 0; j < duration; j++)
                    {
                        Mailbox[(sess - 1) + j, day - 1]++;
                        if (Mailbox[(sess - 1) + j, day - 1] > 1)
                        {
                            MenuItem m = new MenuItem(code.Trim() + "/" + Convert.ToString(j + 1) + " | " + staff.Trim() + " | " + venue.Trim() + " | " + staffterm.Trim() + "\n");
                            MailboxList[(sess - 1) + j, day - 1].Items[0].ChildItems.Add(m);
                        }
                        else
                        {
                            MenuItem m = new MenuItem("");
                            MailboxList[(sess - 1) + j, day - 1] = new Menu();
                            MailboxList[(sess - 1) + j, day - 1].CssClass = "MultipleSessionBox";
                            MailboxList[(sess - 1) + j, day - 1].Font.Name = "Verdana";
                            MailboxList[(sess - 1) + j, day - 1].Font.Size = FontUnit.Point(8);
                            MailboxList[(sess - 1) + j, day - 1].Items.Add(m);
                            MailboxList[(sess - 1) + j, day - 1].Items[0].ChildItems.Add(new MenuItem(code.Trim() + "/" + Convert.ToString(j + 1) + " | " + staff.Trim() + " | " + venue.Trim() + " | " + staffterm.Trim() + "\n"));
                        }
                    }

                    // set the position
                    top = (sess - 1) * BoxHeight;    // sessions and days start at 1
                    left = (day - 1) * BoxWidth;

                    int place = 0;
                    id = Convert.ToInt32(grdTimetable.Rows[i].Cells[14].Text);
                    for (int k = 0; k < modls.Count; k++)
                    {
                        if (id == Convert.ToInt32(modls[k]))
                        {
                            place = k;
                        }
                    }

                    hue = (place * 360) / modls.Count;

                    colorstr = CommonFunctions.HSVtoRGB(hue, 0.07, 1.0);    // 0.2 hsv
                    bordercolor = CommonFunctions.HSVtoRGB(hue, 1.0, 1.0); // 1.0 bordercolor = HSVtoRGB( hue, 0.7, 0.95 );

                    height = (duration * BoxHeight);
                    lblActv[i].Attributes.Add("style", "height:" + height.ToString() + ";position:absolute;left:" + left.ToString() + ";top:" + top.ToString() + ";background-color:" + colorstr + ";border-color:" + bordercolor + ";border-width:3px");
                    panelActivities.Controls.Add(lblActv[i]);
                }

                for (int i = 0; i < timetable.Rows.Length; i++)
                {
                    for (int j = 0; j < timetable.Columns.Length; j++)
                    {
                        // if there are more than 1 entries in a mailbox then visually indicate that there are multiple subjects in a cel
                        if (Mailbox[i, j] > 1)
                        {
                            panelActivities.Controls.Add(drawMultipleIndicator(i, j, MailboxList[i, j]));
                        }
                    }
                }
            }
            catch (ApplicationException ex)
            {
                lblmessage.Visible = true;
                lblmessage.Text = ex.Message;

            }
        }

Am using UltraWebGridDocumentExporter to convert to PDF.

 

Thank you