Welcome Guest Search | Active Topics | Sign In | Register

PROBLEM SOLVED - Items in EO.Web.Grid get hidden after grid.deleteItem() is called Options
kevin2themystic
Posted: Thursday, October 21, 2010 7:05:22 PM
Rank: Newbie
Groups: Member

Joined: 10/21/2010
Posts: 6
Hi,

I am working on a page where I have two grids with (almost) exactly the same columns. The first grid (grid1) displays search results and when the user clicks on an item, I use the ClientSideOnItemSelected event handler to copy that item to the other grid. This is so the user can assign these items to something.

When the form loads, the second grid (grid2) gets populated with a list of items that are already "assigned". When the user clicks one of the items/rows in grid2, I have javascript that checks a column for whether it was "assigned" or not, but in both cases the item gets deleted from the grid (and later the assigned items get deleted in the database, but that is not important).

What I am finding is that when I click on items from grid1, they are successfully populated at the bottom of grid2. If I start clicking on the "assigned" items (which have a different background style) that are close to the bottom of grid2, I see my "unnassigned" items are still there, but when I start clicking on "assigned" items at the top of grid2, the "unnassigned" items start becoming invisible (1 for every "assigned" item I remove). I can however, say that those "unnassigned" items are still in fact in grid2 as I have done a check in javascript code.

Has anyone else come accross this strange anomaly? Any suggestions based on the javascripts below?:

Code: JavaScript
// this method is called in the ClientSideOnItemSelected property of grid1
function ClientSideOnItemSelected(itemSelectedGrid) {
   var selectedItem = itemSelectedGrid.getSelectedItem();
   var messageLabel = document.getElementById('<%= lblMessage.ClientID %>');
   var style = selectedItem.styleSetID;
    if (!CheckProgressAddedByProgressID(selectedItem.getCell(0).getValue())) {
       var grid2= eo_GetObject('<%=grid2.ClientID %>');
       var destinationItem = grid2.addItem();  
       destinationItem.getCell(0).setValue(selectedItem.getCell(0).getValue()); 
       destinationItem.getCell(1).setValue(selectedItem.getCell(1).getValue()); 
       destinationItem.getCell(2).setValue(selectedItem.getCell(2).getValue()); 
       destinationItem.getCell(3).setValue(selectedItem.getCell(3).getValue()); 
       destinationItem.getCell(4).setValue(selectedItem.getCell(4).getValue()); 
       destinationItem.getCell(5).setValue(selectedItem.getCell(5).getValue()); 
       destinationItem.getCell(6).setValue(selectedItem.getCell(6).getValue()); 
       destinationItem.getCell(7).setValue(selectedItem.getCell(7).getValue()); 
       destinationItem.getCell(8).setValue(selectedItem.getCell(8).getValue()); 
       destinationItem.getCell(9).setValue('NotAssigned'); // Type
       destinationItem.ensureVisible();
       messageLabel.innerHTML = '';
   }
   else {
      messageLabel.innerHTML = 'Item was not copied to assigned list as it exists already';
   }
}

// this method is called in the ClientSideOnItemSelected property of grid2
function ClientSideOnItemUnselected(itemSelectedGrid) {
   var selectedItem = itemSelectedGrid.getSelectedItem();
   var messageLabel = document.getElementById('<%= lblMessage.ClientID %>');

    if (selectedItem.getCell(1).getValue() == null) {
      itemSelectedGrid.deleteItem(selectedItem.getIndex());
      messageLabel.innerHTML = '';
    }
   else {
      var unnassign = confirm('<confirmation message>');
      if (unnassign) {
         var progressID = selectedItem.getCell(0).getValue().toString();
         itemSelectedGrid.deleteItem(selectedItem.getIndex());
         messageLabel.innerHTML = '<message>';
      }
   }
}
        
function CheckProgressAddedByProgressID(progressID) {
   var grid2= eo_GetObject('<%=grid2.ClientID %>');
   var count = grid2.getItemCount();
   for (var i = 0; i < count; i++) {
      if (grid2.getItem(i) != null && progressID == grid2.getItem(i).getCell(0).getValue())
                    return true;
      }
      return false;
}


Thank you,
Kevin Parkinson
eo_support
Posted: Friday, October 22, 2010 9:14:17 AM
Rank: Administration
Groups: Administration

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

Your code looks fine to us and the issue you described sounds more like a bug. Can you create a test page to isolate the problem so that we can take a look?

Thanks!
kevin2themystic
Posted: Friday, October 22, 2010 12:15:48 PM
Rank: Newbie
Groups: Member

Joined: 10/21/2010
Posts: 6
eo_support wrote:
Hi,

Your code looks fine to us and the issue you described sounds more like a bug. Can you create a test page to isolate the problem so that we can take a look?

Thanks!


Hello and thanks for your reply. I created a page and was able to duplicate the error.

Here is my Default.aspx code:

Code: HTML/ASPX
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ 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>Essential Objects Grid Test</title>    
    <script language="javascript" type="text/jscript">
       // this function will be called by grdUnpackedProgresses every time an individual item is selected
        function ClientSideOnItemSelected(itemSelectedGrid) {
            var selectedItem = itemSelectedGrid.getSelectedItem();
            var messageLabel = document.getElementById('<%= lblMessage.ClientID %>');
            var style = selectedItem.styleSetID;
            if (!CheckProgressAddedByProgressID(selectedItem.getCell(0).getValue())) {
                var grdAssignProgresses = eo_GetObject('<%=Grid2.ClientID %>');
                var destinationItem = grdAssignProgresses.addItem();  
                // set the ProjectScheduleID and ProjectSchedule and select the row
                destinationItem.getCell(0).setValue(selectedItem.getCell(0).getValue());
                destinationItem.getCell(1).setValue(selectedItem.getCell(1).getValue());
                destinationItem.getCell(2).setValue(selectedItem.getCell(2).getValue()); 
                destinationItem.getCell(3).setValue(selectedItem.getCell(3).getValue()); 
                destinationItem.getCell(4).setValue(selectedItem.getCell(4).getValue());
                destinationItem.getCell(5).setValue(selectedItem.getCell(5).getValue());
                destinationItem.getCell(6).setValue(selectedItem.getCell(6).getValue());
                destinationItem.getCell(7).setValue(selectedItem.getCell(7).getValue());
                destinationItem.getCell(8).setValue(selectedItem.getCell(8).getValue());
                destinationItem.getCell(9).setValue(''); // Type
                destinationItem.ensureVisible();
                messageLabel.innerHTML = '';
            }
            else {
                messageLabel.innerHTML = 'Item was not copied to assigned list as it exists already';
            }
        }

        // this function will be called by grdUnpackedProgresses every time an individual item is selected
        function ClientSideOnItemUnselected(itemSelectedGrid) {
            var selectedItem = itemSelectedGrid.getSelectedItem();
            var messageLabel = document.getElementById('<%= lblMessage.ClientID %>');

            // Check if the item has already been assigned to the work package
            if (selectedItem.getCell(1).getValue() == null) {
                itemSelectedGrid.deleteItem(selectedItem.getIndex());
                messageLabel.innerHTML = '';
            }
            else {
                var unnassign = confirm('This item has already been assigned. Click OK to unnassign it or cancel to preserve the assignment');
                if (unnassign) {
                    var progressID = selectedItem.getCell(0).getValue().toString();
                    itemSelectedGrid.deleteItem(selectedItem.getIndex());
                    messageLabel.innerHTML = 'The record has been unnasigned';
                }
            }
        }
        
        function CheckProgressAddedByProgressID(progressID) {
            var grdAssignProgresses = eo_GetObject('<%=Grid2.ClientID %>');
            var count = grdAssignProgresses.getItemCount();
            for (var i = 0; i < count; i++) {
                // check if grdAssignProgresses.getItem(i) != null because there seems
                // to be a bug with grdAssignProgresses.getItemCount(): when items are deleted from the grid
                // it doesn't update the item count
                // we only want to do this search if there are currently items in the grid
                // getItem(i).getCell(0) is the ProgressID column
                if (grdAssignProgresses.getItem(i) != null && progressID == grdAssignProgresses.getItem(i).getCell(0).getValue())
                    return true;
            }
            return false;
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>              
        <eo:Grid ID="Grid1" Height="160px" runat="server" Width="725px" 
            GridLines="Both" BorderWidth="1px" BackColor="White" BorderColor="#828790" 
            ColumnHeaderAscImage="00050204"  ColumnHeaderDescImage="00050205" 
            ColumnHeaderDividerImage="00050203" ColumnHeaderHeight="24" 
            EnableKeyboardNavigation="True" Font-Names="Tahoma" 
            Font-Size="8pt" GridLineColor="240, 240, 240" ItemHeight="19" 
            ForeColor="Black" Font-Bold="False" Font-Italic="False" Font-Overline="False" 
            Font-Strikeout="False" Font-Underline="False" 
            ClientSideOnItemSelected="ClientSideOnItemSelected">
            <ColumnHeaderStyle CssText="background-image:url('00050201');font-weight:bold;padding-left:8px;padding-top:4px;" />
            <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;white-space:nowrap;" />
                </eo:GridItemStyleSet>
            </ItemStyles>
            <ColumnHeaderHoverStyle CssText="background-image:url('00050202');padding-left:8px;padding-top:4px; font-size: 12px; font-weight: bold;" />
            <ColumnHeaderTextStyle CssText="font-weight:bold;" />
            <Columns>
                <eo:StaticColumn DataField="PID" HeaderText="PID" Name="PID" Visible="False" Width="10" />
                <eo:StaticColumn DataField="WID" HeaderText="WID" Name="WID" Visible="False" 
                    Width="10" />
                <eo:StaticColumn DataField="C" HeaderText="C" Name="C" AllowSort="True" />
                <eo:StaticColumn DataField="D" HeaderText="D" Name="D" AllowSort="True" />
                <eo:StaticColumn DataField="T" HeaderText="T" Name="T" AllowSort="True" />
                <eo:StaticColumn DataField="P" HeaderText="P" Name="P" AllowSort="True" />
                <eo:StaticColumn DataField="L" HeaderText="L" Name="L" AllowSort="True"><CellStyle CssText="text-align:right" /></eo:StaticColumn>
                <eo:StaticColumn DataField="U" HeaderText="U" Name="U" AllowSort="True" />
                <eo:StaticColumn DataField="M" HeaderText="M" Name="M" AllowSort="True"><CellStyle CssText="text-align:right" /></eo:StaticColumn>
            </Columns>
        </eo:Grid> 
        <hr style="width:650px" align="left" />
        <eo:Grid ID="Grid2" Height="160px" runat="server"  Width="825px" 
            GridLines="Both" BorderWidth="1px" BackColor="White" BorderColor="#828790" 
            ColumnHeaderAscImage="00050204" ColumnHeaderDescImage="00050205" 
            ColumnHeaderDividerImage="00050203" ClientSideOnItemSelected="ClientSideOnItemUnselected" 
            ColumnHeaderHeight="24" EnableKeyboardNavigation="True" 
            Font-Names="Tahoma" Font-Size="8pt"
            GridLineColor="240, 240, 240" ItemHeight="19" ForeColor="Black" 
            Font-Bold="False" Font-Italic="False" Font-Overline="False" 
            Font-Strikeout="False" Font-Underline="False" StyleSetIDField="Type" >
            <ColumnHeaderStyle CssText="background-image:url('00050201');font-weight:bold;padding-left:8px;padding-top:4px;" />
            <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;white-space:nowrap;" />
                </eo:GridItemStyleSet>
                <eo:GridItemStyleSet StyleSetID="Assigned">
                    <ItemStyle CssText="background-color: #cccba9" />
                    <ItemHoverStyle CssText="background-color: #bbba98" />
                    <CellStyle CssText="padding-left:8px;padding-top:2px;white-space:nowrap;" />
                </eo:GridItemStyleSet>
            </ItemStyles>
            <ColumnHeaderHoverStyle CssText="background-image:url('00050202');padding-left:8px;padding-top:4px; font-size: 12px; font-weight: bold;" />
            <ColumnHeaderTextStyle CssText="font-weight:bold;" />
            <Columns>
            <eo:StaticColumn DataField="PID" HeaderText="PID" Name="PID" Visible="False" Width="10" />
            <eo:StaticColumn DataField="WPID" HeaderText="WPID" Name="WPID" Visible="False" Width="10" />
            <eo:StaticColumn DataField="C" HeaderText="C" Name="C" AllowSort="True" />
            <eo:StaticColumn DataField="D" HeaderText="D" Name="D" AllowSort="True" />
            <eo:StaticColumn DataField="T" HeaderText="T" Name="T" AllowSort="True" />
            <eo:StaticColumn DataField="P" HeaderText="P" Name="P" AllowSort="True" />
            <eo:StaticColumn DataField="L" HeaderText="L" Name="L" AllowSort="True"><CellStyle CssText="text-align:right" /></eo:StaticColumn>
            <eo:StaticColumn DataField="U" HeaderText="U" Name="U" AllowSort="True" />
            <eo:StaticColumn DataField="M" HeaderText="M" Name="M" AllowSort="True"><CellStyle CssText="text-align:right" /></eo:StaticColumn>
            <eo:StaticColumn DataField="Type" HeaderText="Type" Name="Type" Visible="true" />
            </Columns>
        </eo:Grid>
    </div>
    <asp:Label ID="lblMessage" runat="server" Text="Label"></asp:Label>
    </form>
</body>
</html>


Here is my Default.aspx.cs code behind file:

Code: C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using EO.Web;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        LoadGrid1();
        LoadGrid2();
    }

    private void LoadGrid1()
    {
        for(int i = 0; i < 100; i++)
        {
            GridItem gItem = Grid1.CreateItem();
            gItem.Cells["PID"].Value   = i.ToString() + "-A-OriginateGrid1";
            gItem.Cells["WID"].Value  = i.ToString() + "-B-OriginateGrid1";
            gItem.Cells["C"].Value = i.ToString() + "-C-OriginateGrid1";
            gItem.Cells["D"].Value = i.ToString() + "-D-OriginateGrid1";
            gItem.Cells["T"].Value  = i.ToString() + "-E-OriginateGrid1";
            gItem.Cells["P"].Value  = i.ToString() + "-F-OriginateGrid1";
            gItem.Cells["L"].Value   = i.ToString() + "-G-OriginateGrid1";
            gItem.Cells["U"].Value   = i.ToString() + "-H-OriginateGrid1";
            gItem.Cells["M"].Value    = i.ToString() + "-I-OriginateGrid1";

            Grid1.Items.Add(gItem);
        }

    }

    private void LoadGrid2()
    {
        for(int i = 0; i < 100; i++)
        {
            GridItem gItem = Grid2.CreateItem();
            gItem.Cells["PID"].Value   = i.ToString() + "-A-OriginateGrid2";
            gItem.Cells["WPID"].Value  = i.ToString() + "-B-OriginateGrid2";
            gItem.Cells["C"].Value = i.ToString() + "-C-OriginateGrid2";
            gItem.Cells["D"].Value = i.ToString() + "-D-OriginateGrid2";
            gItem.Cells["T"].Value  = i.ToString() + "-E-OriginateGrid2";
            gItem.Cells["P"].Value  = i.ToString() + "-F-OriginateGrid2";
            gItem.Cells["L"].Value   = i.ToString() + "-G-OriginateGrid2";
            gItem.Cells["U"].Value   = i.ToString() + "-H-OriginateGrid2";
            gItem.Cells["M"].Value    = i.ToString() + "-I-OriginateGrid2";            
            gItem.Cells["Type"].Value  = "Assigned";
            Grid2.Items.Add(gItem);
        }
    }
}


Thanks a lot for your help!

P.S. - If you find this actually is a bug, do I get a medal or something? ; )
eo_support
Posted: Friday, October 22, 2010 2:22:14 PM
Rank: Administration
Groups: Administration

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

Can you check which version you are running? We tested your code on the latest version and it works fine. Our steps are:

1. Click any item in Grid1. The item is added to the bottom of Grid2;
2. Without scrolling Grid2, click any "assigned" item. The clicked item is deleted;
3. Scroll to the top of Grid2, click any "assigned" item. The clicked item is deleted;
4. Scroll to the bottom of Grid2, the last item, which was added in step 1, is still there;

Can you let us know if this is the intended result?

Thanks!
kevin2themystic
Posted: Friday, October 22, 2010 2:31:38 PM
Rank: Newbie
Groups: Member

Joined: 10/21/2010
Posts: 6
Hi There,

Yes, the 4 steps you listed are the intended results, but step number 4 is the one where I am not seeing the item even though I know it is still there in the list AND I have made sure to set ensureVisible() on the item.

I looked at my EO.Web.dll and the version is: 7.0.62.2.

Do you suggest an upgrade?

Thanks!

Kevin
eo_support
Posted: Friday, October 22, 2010 2:35:37 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Yes. You will want to try the current version. If you already have a license, you can go to your license key page to see if you can receive a new license for the new version for free. You should be able to have it if your order was placed within one year. If you have already past the one year limit, then you will need to place an upgrade order in order to use the new version.

Thanks!
kevin2themystic
Posted: Friday, October 22, 2010 2:37:25 PM
Rank: Newbie
Groups: Member

Joined: 10/21/2010
Posts: 6
P.S. - I am also having some weird behaviour in the grid when adding and deleting multiple items: getItemCount() not being updated correctly, the grid having problems that looks like a painting issue and items not showing up in the grid when added from the other grid.
kevin2themystic
Posted: Friday, October 22, 2010 4:24:07 PM
Rank: Newbie
Groups: Member

Joined: 10/21/2010
Posts: 6
PROBLEM SOLVED! I was using version 7 of EO instead of 8. I referenced the v8 dll and all the aforementioned problems disappeared.

Thanks!
eo_support
Posted: Friday, October 22, 2010 4:26:19 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Great. Glad that it worked for you!


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.