Welcome Guest Search | Active Topics | Sign In | Register

Treeview Image not correct Options
Philipp Jenni
Posted: Tuesday, July 29, 2008 5:03:16 AM
Rank: Advanced Member
Groups: Member

Joined: 6/9/2007
Posts: 98
Hi,

I have created a browser window that display all images on the webserver. I have implemented a new, delete and rename directory function. When i a folder now, the display the treeview control the last image not correct. It display a not found image.

I have create a sample page for you, but you must create a folderstructure in your web. Set the
rootpath and the firstpath constant in my code. The firstpath constant must be a directory in the rootpath. Then create in a directory more than one folder an delete one of the with the context menu "Verzeichnis löschen".

Than you see, the last nodes of each tree hasn't an image.

Here is my sample page:

Code: HTML/ASPX
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="eoTest.aspx.cs" Inherits="eoTest" %>
<%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<script type="text/javascript" language="javascript">
   function beginEditTree() {
    eo_GetObject('treeDialogUploadVerzeichnis').getSelectedNode().beginEdit('');
   }
</script>
<body>
    <form id="form1" runat="server">
    <div>
    
        <table style="width: auto;">
            <tr>
                <td style="width: 220px; vertical-align: top;">
                    <eo:TreeView ID="treeDialogUploadVerzeichnis" runat="server" ControlSkinID="None"
                        Height="250px" Width="220px"
                        ClientSideOnItemClick="" RaisesServerEvent="True" AllowEdit="True" 
                        OnItemRenamed="treeDialogUploadVerzeichnis_ItemRenamed">
                        <LookNodes>
                            <eo:TreeNode CollapsedImageUrl="00030301" DisabledStyle-CssText="background-color:transparent;border-bottom-style:none;border-left-style:none;border-right-style:none;border-top-style:none;color:Gray;padding-bottom:1px;padding-left:1px;padding-right:1px;padding-top:1px;"
                                ExpandedImageUrl="00030302" ImageUrl="00030301" ItemID="_Default" NormalStyle-CssText="PADDING-RIGHT: 1px; PADDING-LEFT: 1px; PADDING-BOTTOM: 1px; COLOR: black; BORDER-TOP-STYLE: none; PADDING-TOP: 1px; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: transparent; BORDER-BOTTOM-STYLE: none"
                                SelectedStyle-CssText="background-color:#316ac5;border-bottom-color:#999999;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#999999;border-left-style:solid;border-left-width:1px;border-right-color:#999999;border-right-style:solid;border-right-width:1px;border-top-color:#999999;border-top-style:solid;border-top-width:1px;color:White;padding-bottom:0px;padding-left:0px;padding-right:0px;padding-top:0px;">
                            </eo:TreeNode>
                        </LookNodes>
                        <TopGroup Style-CssText="border-bottom-color:#999999;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#999999;border-left-style:solid;border-left-width:1px;border-right-color:#999999;border-right-style:solid;border-right-width:1px;border-top-color:#999999;border-top-style:solid;border-top-width:1px;color:black;cursor:hand;font-family:Tahoma;font-size:8pt;padding-bottom:2px;padding-left:2px;padding-right:2px;padding-top:2px;">
                        </TopGroup>
                    </eo:TreeView>
                </td>
                <td style="vertical-align: top;">
                    <eo:Grid ID="gridDialogUploadDateien" runat="server" BorderColor="#828790" BorderWidth="1px"
                        ClientSideOnItemSelected="setSelectedPath" ColumnHeaderAscImage="00050204" ColumnHeaderDescImage="00050205"
                        ColumnHeaderDividerImage="00050203" ColumnHeaderHeight="24" FixedColumnCount="1"
                        Font-Bold="False" Font-Italic="False" Font-Names="Tahoma" Font-Overline="False"
                        Font-Size="8pt" Font-Strikeout="False" Font-Underline="False" GridLineColor="240, 240, 240"
                        GridLines="Both" Height="258px" ItemHeight="16" PageSize="10" Width="530px">
                        <FooterStyle CssText="padding-bottom:4px;padding-left:4px;padding-right:4px;padding-top:4px;" />
                        <ItemStyles>
                            <eo:GridItemStyleSet>
                                <ItemStyle CssText="background-color: white" />
                                <ItemHoverStyle CssText="background-image: url(00050206); background-repeat: repeat-x" />
                                <SelectedStyle CssText="background-image: url(00050207); background-repeat: repeat-x" />
                                <CellStyle CssText="padding-left:8px;padding-top:2px;" />
                            </eo:GridItemStyleSet>
                        </ItemStyles>
                        <ColumnTemplates>
                            <eo:TextBoxColumn>
                                <TextBoxStyle CssText="BORDER-RIGHT: #7f9db9 1px solid; PADDING-RIGHT: 2px; BORDER-TOP: #7f9db9 1px solid; PADDING-LEFT: 2px; FONT-SIZE: 8.75pt; PADDING-BOTTOM: 1px; MARGIN: 0px; BORDER-LEFT: #7f9db9 1px solid; PADDING-TOP: 2px; BORDER-BOTTOM: #7f9db9 1px solid; FONT-FAMILY: Tahoma" />
                            </eo:TextBoxColumn>
                            <eo:DateTimeColumn>
                                <DatePicker ControlSkinID="None" DayCellHeight="16" DayCellWidth="19" DayHeaderFormat="FirstLetter"
                                    DisabledDates="" OtherMonthDayVisible="True" SelectedDates="" TitleLeftArrowImageUrl="DefaultSubMenuIconRTL"
                                    TitleRightArrowImageUrl="DefaultSubMenuIcon">
                                    <TodayStyle CssText="font-family: tahoma; font-size: 12px; border-right: #bb5503 1px solid; border-top: #bb5503 1px solid; border-left: #bb5503 1px solid; border-bottom: #bb5503 1px solid" />
                                    <SelectedDayStyle CssText="font-family: tahoma; font-size: 12px; background-color: #fbe694; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid" />
                                    <DisabledDayStyle CssText="font-family: tahoma; font-size: 12px; color: gray; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid" />
                                    <PickerStyle CssText="border-bottom-color:#7f9db9;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#7f9db9;border-left-style:solid;border-left-width:1px;border-right-color:#7f9db9;border-right-style:solid;border-right-width:1px;border-top-color:#7f9db9;border-top-style:solid;border-top-width:1px;font-family:Courier New;font-size:8pt;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px;padding-bottom:1px;padding-left:2px;padding-right:2px;padding-top:2px;" />
                                    <CalendarStyle CssText="background-color: white; border-right: #7f9db9 1px solid; padding-right: 4px; border-top: #7f9db9 1px solid; padding-left: 4px; font-size: 9px; padding-bottom: 4px; border-left: #7f9db9 1px solid; padding-top: 4px; border-bottom: #7f9db9 1px solid; font-family: tahoma" />
                                    <TitleArrowStyle CssText="cursor:hand" />
                                    <DayHoverStyle CssText="font-family: tahoma; font-size: 12px; border-right: #fbe694 1px solid; border-top: #fbe694 1px solid; border-left: #fbe694 1px solid; border-bottom: #fbe694 1px solid" />
                                    <MonthStyle CssText="font-family: tahoma; font-size: 12px; margin-left: 14px; cursor: hand; margin-right: 14px" />
                                    <TitleStyle CssText="background-color:#9ebef5;font-family:Tahoma;font-size:12px;padding-bottom:2px;padding-left:6px;padding-right:6px;padding-top:2px;" />
                                    <OtherMonthDayStyle CssText="font-family: tahoma; font-size: 12px; color: gray; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid" />
                                    <DayHeaderStyle CssText="font-family: tahoma; font-size: 12px; border-bottom: #aca899 1px solid" />
                                    <DayStyle CssText="font-family: tahoma; font-size: 12px; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid" />
                                </DatePicker>
                            </eo:DateTimeColumn>
                            <eo:MaskedEditColumn>
                                <MaskedEdit ControlSkinID="None" TextBoxStyle-CssText="BORDER-RIGHT: #7f9db9 1px solid; PADDING-RIGHT: 2px; BORDER-TOP: #7f9db9 1px solid; PADDING-LEFT: 2px; PADDING-BOTTOM: 1px; MARGIN: 0px; BORDER-LEFT: #7f9db9 1px solid; PADDING-TOP: 2px; BORDER-BOTTOM: #7f9db9 1px solid; font-family:Courier New;font-size:8pt;">
                                </MaskedEdit>
                            </eo:MaskedEditColumn>
                        </ColumnTemplates>
                        <ColumnHeaderHoverStyle CssText="background-image:url('00050202');padding-left:8px;padding-top:4px;" />
                        <Columns>
                            <eo:RowNumberColumn Width="50">
                            </eo:RowNumberColumn>
                            <eo:StaticColumn AllowSort="True" DataField="File" HeaderText="File" Text="" Width="300">
                            </eo:StaticColumn>
                            <eo:StaticColumn AllowSort="True" DataField="Size" HeaderText="Size" Text="">
                            </eo:StaticColumn>
                            <eo:StaticColumn AllowSort="True" DataField="Extension" HeaderText="Extension" Width="80">
                            </eo:StaticColumn>
                        </Columns>
                        <ColumnHeaderStyle CssText="background-image:url('00050201');padding-left:8px;padding-top:4px;" />
                    </eo:Grid>
                </td>
            </tr>
            <tr>
                <td class="style1" colspan="2">
                    <eo:ContextMenu ID="ContextMenu1" runat="server" ContextControlID="treeDialogUploadVerzeichnis"
                        ControlSkinID="None" Width="200px" CheckIconUrl="OfficeCheckIcon" OnItemClick="ContextMenu1_ItemClick"
                        RaisesServerEvent="True" ClientSideOnItemClick="">
                        <LookItems>
                            <eo:MenuItem HoverStyle-CssText="background-color:#c1d2ee;border-bottom-color:#316ac5;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#316ac5;border-left-style:solid;border-left-width:1px;border-right-color:#316ac5;border-right-style:solid;border-right-width:1px;border-top-color:#316ac5;border-top-style:solid;border-top-width:1px;padding-left:4px;padding-right:4px;padding-top:0px;padding-bottom:0px;"
                                ItemID="_TopLevelItem" NormalStyle-CssText="background-color:transparent;border-bottom-style:none;border-left-style:none;border-right-style:none;border-top-style:none;padding-bottom:1px;padding-left:5px;padding-right:5px;padding-top:1px;"
                                DisabledStyle-CssText="background-color:transparent;border-bottom-style:none;border-left-style:none;border-right-style:none;border-top-style:none;padding-bottom:1px;padding-left:5px;padding-right:5px;padding-top:1px;color:lightgrey"
                                Height="24" SelectedStyle-CssText="background-color:white;border-bottom-color:#316ac5;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#316ac5;border-left-style:solid;border-left-width:1px;border-right-color:#316ac5;border-right-style:solid;border-right-width:1px;border-top-color:#316ac5;border-top-style:solid;border-top-width:1px;padding-left:4px;padding-right:4px;padding-top:0px;padding-bottom:0px;">
                                <SubMenu ItemSpacing="3" Style-CssText="background-color:#fcfcf9;border-bottom-color:#999999;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#999999;border-left-style:solid;border-left-width:1px;border-right-color:#999999;border-right-style:solid;border-right-width:1px;border-top-color:#999999;border-top-style:solid;border-top-width:1px;color:black;cursor:hand;font-family:Tahoma;font-size:8pt;padding-bottom:1px;padding-left:1px;padding-right:1px;padding-top:1px;"
                                    CollapseEffect-Duration="150" CollapseEffect-Type="Fade" ExpandEffect-Duration="150"
                                    ExpandEffect-Type="Fade" LeftIconCellWidth="25" SideImage="OfficeXPSideBar">
                                </SubMenu>
                            </eo:MenuItem>
                            <eo:MenuItem IsSeparator="True" ItemID="_Separator" NormalStyle-CssText="background-color:#c5c2b8;height:1px;margin-left:30px;width:1px;">
                            </eo:MenuItem>
                            <eo:MenuItem HoverStyle-CssText="background-color:#c1d2ee;border-bottom-color:#316ac5;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#316ac5;border-left-style:solid;border-left-width:1px;border-right-color:#316ac5;border-right-style:solid;border-right-width:1px;border-top-color:#316ac5;border-top-style:solid;border-top-width:1px;padding-left:1px;padding-right:4px;padding-top:0px;"
                                ItemID="_Default" NormalStyle-CssText="background-color:transparent;border-bottom-style:none;border-left-style:none;border-right-style:none;border-top-style:none;padding-bottom:1px;padding-left:2px;padding-right:5px;padding-top:1px;"
                                DisabledStyle-CssText="background-color:transparent;border-bottom-style:none;border-left-style:none;border-right-style:none;border-top-style:none;padding-bottom:1px;padding-left:2px;padding-right:5px;padding-top:1px;color:lightgrey"
                                Height="24" SelectedStyle-CssText="background-color:white;border-bottom-color:#316ac5;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#316ac5;border-left-style:solid;border-left-width:1px;border-right-color:#316ac5;border-right-style:solid;border-right-width:1px;border-top-color:#316ac5;border-top-style:solid;border-top-width:1px;padding-left:1px;padding-right:4px;padding-top:0px;"
                                Text-Padding-Right="30">
                                <SubMenu ItemSpacing="3" Style-CssText="background-color:#fcfcf9;border-bottom-color:#999999;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#999999;border-left-style:solid;border-left-width:1px;border-right-color:#999999;border-right-style:solid;border-right-width:1px;border-top-color:#999999;border-top-style:solid;border-top-width:1px;color:black;cursor:hand;font-family:Tahoma;font-size:8pt;padding-bottom:1px;padding-left:1px;padding-right:1px;padding-top:1px;"
                                    CollapseEffect-Duration="150" CollapseEffect-Type="Fade" ExpandEffect-Duration="150"
                                    ExpandEffect-Type="Fade" LeftIconCellWidth="25" SideImage="OfficeXPSideBar">
                                </SubMenu>
                            </eo:MenuItem>
                        </LookItems>
                        <TopGroup Orientation="Vertical">
                            <Items>
                                <eo:MenuItem Text-Html="Neues Verzeichnis" Value="newdir">
                                </eo:MenuItem>
                                <eo:MenuItem IsSeparator="True">
                                </eo:MenuItem>
                                <eo:MenuItem ItemID="renamedir" RaisesServerEvent="False" 
                                    Text-Html="Verzeichnis umbenennen" 
                                    OnClickScript="eo_GetObject('treeDialogUploadVerzeichnis').getSelectedNode().beginEdit('')">
                                </eo:MenuItem>
                                <eo:MenuItem Text-Html="Verzeichnis löschen" Value="removedir">
                                </eo:MenuItem>
                            </Items>
                        </TopGroup>
                    </eo:ContextMenu>
                </td>
            </tr>
        </table>

    
    </div>
    </form>
</body>
</html>


Code: C#
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.IO;

public partial class eoTest : System.Web.UI.Page
{
    private const string rootpath = "Public\\Demo";
    private const string firstdir = "\\Image";


    protected void Page_Load(object sender, EventArgs e)
    {
        loadTree(false);
    }

    private void loadSubDirs(string dir, ref int id, int parent, DataTable table)
    {
        id++;
        if (parent == 0)
        {
            table.Rows.Add(new Object[] { id, null, Path.GetFileName(dir).ToString() });
        }
        else
        {
            table.Rows.Add(new Object[] { id, parent, Path.GetFileName(dir).ToString() });
        }
        parent = id;
        string[] subdirs = Directory.GetDirectories(dir);
        foreach (string subdir in subdirs)
        {
            loadSubDirs(subdir, ref id, parent, table);
        }
    }

    private string getPath(EO.Web.TreeNode e)
    {
        string path = "";
        if (e.ParentNode.Text != null)
        {
            path = getPath(e.ParentNode);
        }
        return path + "\\" + e.Text;
    }

    private void loadFiles(string path)
    {
        FileInfo oFile;

        string script = "&lt;script language=\"JavaScript\"&gt;\n" +
                        "function setSelectedPath() {\n" +
                        "document.getElementById('eo_editor_insertimage_url').value = '" + path.Replace("\\", "\\\\") + "\\\\' + eo_GetObject('gridDialogUploadDateien').getSelectedItem().getCell(1).getValue(); \n } \n" +
                        "&lt;/script&gt;\n";

        // "document.getElementById('Text1').value = document.getElementById('TextBox1').value + '\\' + eo_GetObject('Grid1').getSelectedItem().getCell(1).getValue();";

        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "setSelectedPath", script);

        DataTable table = new DataTable();
        table.Columns.Add(new DataColumn("File"));
        table.Columns.Add(new DataColumn("Size"));
        table.Columns.Add(new DataColumn("Extension"));

        foreach (string file in Directory.GetFiles(Server.MapPath(rootpath + path)))
        {
            oFile = new FileInfo(file);
            table.Rows.Add(new Object[] { Path.GetFileName(file), oFile.Length, Path.GetExtension(file) });
        }
        gridDialogUploadDateien.DataSource = table;
        gridDialogUploadDateien.DataBind();
    }

    protected void ContextMenu1_ItemClick(object sender, EO.Web.NavigationItemEventArgs e)
    {
        string path = Server.MapPath(rootpath + getPath(treeDialogUploadVerzeichnis.SelectedNode));


        if (e.MenuItem.Value == "newdir")
        {
            int i = 0;
            string newDirName = "\\Neuer Ordner";
            while (Directory.Exists(path + newDirName) == true)
            {
                i++;
                newDirName = "\\Neuer Ordner " + i.ToString();
            }
            Directory.CreateDirectory(path + newDirName);
            string pathvar = treeDialogUploadVerzeichnis.SelectedNode.Path;
            loadTree(true);
            treeDialogUploadVerzeichnis.FindItem(pathvar).Selected = true;
            treeDialogUploadVerzeichnis.SelectedNode.ExpandPath();
        }
        if (e.MenuItem.Value == "removedir")
        {
            Directory.Delete(path, true);
            string pathvar = treeDialogUploadVerzeichnis.SelectedNode.ParentNode.Path;
            loadTree(true);
            treeDialogUploadVerzeichnis.FindItem(pathvar).Selected = true;
            treeDialogUploadVerzeichnis.SelectedNode.ExpandPath();
            // treeDialogUploadVerzeichnis.SelectedNode.ParentNode.Expanded = false;
        }



    }

    private void loadTree(bool force)
    {
        if (treeDialogUploadVerzeichnis.Nodes.Count == 0 | force == true)
        {
            treeDialogUploadVerzeichnis.Nodes.Clear();
            DataTable table = new DataTable();
            table.Columns.Add(new DataColumn("ID"));
            table.Columns.Add(new DataColumn("ParentID"));
            table.Columns.Add(new DataColumn("Text"));

            int id = 0;

            loadSubDirs(Server.MapPath(rootpath + firstdir), ref id, 0, table);
            DataSet set = new DataSet();
            set.Tables.Add(table);
            set.Relations.Add(table.Columns[0], table.Columns[1]);
            set.Relations[0].Nested = true;

            treeDialogUploadVerzeichnis.DataSource = set;
            treeDialogUploadVerzeichnis.DataFields = "Text";
            treeDialogUploadVerzeichnis.DataBind();
            treeDialogUploadVerzeichnis.Nodes[0].Expanded = true;
            loadFiles("\\Image");
        }
    }

    protected void treeDialogUploadVerzeichnis_ItemRenamed(object sender, EO.Web.TreeNodeRenameEventArgs e)
    {
        if (e.Node.Text != e.OldText)
        {
            string path = Server.MapPath(rootpath + getPath(treeDialogUploadVerzeichnis.SelectedNode));
            Directory.Move(Directory.GetParent(path) + "\\" + e.OldText, path);
            loadTree(true);
        }
    }
}

eo_support
Posted: Tuesday, July 29, 2008 6:35:17 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,221
Thanks for reporting the issue. We will look into it and see what we can find.
eo_support
Posted: Wednesday, July 30, 2008 1:02:18 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,221
Hi,

We tested the code and it works fine. Do you have the page online so that we can see the problem?

Thanks
Philipp Jenni
Posted: Monday, August 4, 2008 11:13:40 AM
Rank: Advanced Member
Groups: Member

Joined: 6/9/2007
Posts: 98
It works by also. I have restart the internal webserver and it works now. But i don't know why this it so now.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.