Rank: Newbie Groups: Member
Joined: 10/1/2014 Posts: 2
|
Hello, I'm have an issue when I Delete an item in a Grid with RunningMode="Callback" and AllowPaging="true". Sometimes when I delete an item the paging crash and looks like i have only 1 page (even if the item displayed on screen are in the 2nd page). From that point i can't do anything and i have to reload the page. I'm probably not clear (sorry for my english) so here is an example that reproduce my issue. I used the demo of the Grid Demos/Grid/Features/Callback Running Mode/Demo.aspx
Code: HTML/ASPX
<%@ Register TagPrefix="eo" Namespace="EO.Web" Assembly="EO.Web" %>
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Demo.aspx.cs" Inherits="Demos_Grid_Features_Callback_Running_Mode_Demo" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="demo" runat="Server">
<script type="text/javascript">
function GridUpdate() {
eo_Callback('CallbackPanel');
}
function OnItemDelete(grid, itemIndex, colIndex, commandName) {
if (window.confirm("Are you sure ?")) {
grid.deleteItem(itemIndex);
}
}
</script>
<p>
<eo:CallbackPanel runat="server" ID="CallbackPanel" AutoDisableContents="True">
<eo:Grid ID="Grid1" runat="server" BorderWidth="1px" Font-Size="8.75pt" KeyField="TopicID" Font-Names="Tahoma"
ColumnHeaderDescImage="00050105" FixedColumnCount="1" Width="650px" ColumnHeaderDividerImage="00050103"
GridLineColor="220, 223, 228" BorderColor="#7F9DB9" PageSize="10" GridLines="Both" GoToBoxVisible="True"
Height="300px" ColumnHeaderAscImage="00050104" AllowPaging="True" RunningMode="Callback"
OnPageIndexChanged="Grid1_PageIndexChanged" ClientSideOnItemCommand="OnItemDelete" OnItemDeleted="Grid1_ItemDeleted" OnColumnSort="Grid1_ColumnSort">
<FooterStyle CssText="padding-bottom:4px;padding-left:4px;padding-right:4px;padding-top:4px;"></FooterStyle>
<ItemStyles>
<eo:GridItemStyleSet>
<CellStyle CssText="padding-left:8px;padding-top:2px;"></CellStyle>
<FixedColumnCellStyle CssText="border-right: #d6d2c2 1px solid; padding-right: 10px; border-top: #faf9f4 1px solid; border-left: #faf9f4 1px solid; border-bottom: #d6d2c2 1px solid; background-color: #ebeadb; text-align: right"></FixedColumnCellStyle>
</eo:GridItemStyleSet>
</ItemStyles>
<GoToBoxStyle CssText="BORDER-RIGHT: #7f9db9 1px solid; BORDER-TOP: #7f9db9 1px solid; BORDER-LEFT: #7f9db9 1px solid; WIDTH: 40px; BORDER-BOTTOM: #7f9db9 1px solid"></GoToBoxStyle>
<ContentPaneStyle 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;"></ContentPaneStyle>
<Columns>
<eo:ButtonColumn ButtonText="Delete" CommandName="Delete"></eo:ButtonColumn>
<eo:StaticColumn DataField="TopicID" AllowSort="True" HeaderText="Topic" Width="300"></eo:StaticColumn>
</Columns>
<ColumnHeaderStyle CssText="background-image:url('00050101');padding-left:8px;padding-top:3px;"></ColumnHeaderStyle>
</eo:Grid>
</eo:CallbackPanel>
</p>
</asp:Content>
Code: C#
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
using EO.Web.Demo;
public partial class Demos_Grid_Features_Callback_Running_Mode_Demo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Grid1.IsCallbackByMe)
{
SetRecordCount();
LoadGridData(null);
}
}
#region SAMPLE_BLOCK#1
private void SetRecordCount()
{
using (DemoDB db = new DemoDB())
{
string sql = "SELECT COUNT(*) FROM Topics";
int nRecordCount = (int)db.ExecuteScalar(sql);
Grid1.RecordCount = nRecordCount;
}
}
private void LoadGridData(EO.Web.GridColumn sortColumn)
{
SetRecordCount();
string sortField;
string sortOrder;
if (sortColumn == null)
sortColumn = Grid1.SortColumn;
if (sortColumn != null)
{
sortField = sortColumn.DataField;
sortOrder = sortColumn.SortOrder == EO.Web.SortOrder.Ascending ? "ASC" : "DESC";
}
else
{
sortField = "TopicID";
sortOrder = "DESC";
}
string sortOrderReverse = sortOrder == "ASC" ? "DESC" : "ASC";
using (DemoDB db = new DemoDB())
{
//Number of records to display in the current page
int recordsForCurrentPage = Grid1.PageSize;
//Number of records included by the current page and
//all pages before the current page
int recordsTillCurrentPage = (Grid1.CurrentPage + 1) * Grid1.PageSize;
//The current page may be the last page, in which
//case the total number of available records may
//be less than PageSize
if (recordsTillCurrentPage > Grid1.RecordCount)
{
recordsForCurrentPage -= recordsTillCurrentPage - Grid1.RecordCount;
recordsTillCurrentPage = Grid1.RecordCount;
}
string sql1 = string.Format(
"SELECT TOP {0} * FROM Topics ORDER BY {1} {2}",
recordsTillCurrentPage, sortField, sortOrder);
string sql2 = string.Format(
"SELECT TOP {0} * FROM ({1}) ORDER BY {2} {3}",
recordsForCurrentPage, sql1, sortField, sortOrderReverse);
string sql3 = string.Format(
"SELECT * FROM ({0}) ORDER BY {1} {2}",
sql2, sortField, sortOrder);
OleDbDataReader reader = db.ExecuteReader(sql3);
Grid1.DataSource = reader;
Grid1.DataBind();
}
}
#endregion
protected void Grid1_PageIndexChanged(object sender, System.EventArgs e)
{
LoadGridData(null);
}
protected void Grid1_ColumnSort(object sender, EO.Web.GridColumnEventArgs e)
{
LoadGridData(e.Column);
}
protected void Grid1_ItemDeleted(object sender, EO.Web.GridItemEventArgs e)
{
using (DemoDB db = new DemoDB())
{
string sql = "DELETE FROM Topics WHERE TopicID = " + e.Item.Key;
db.ExecuteScalar(sql);
LoadGridData(null);
}
}
}
To reproduce this issue I used 12 Topics (I deleted the other ones). I go on page 2, delete 1 Topic and the issue will apear (I hope it will ...). I'm able to reproduce this 100% times. Thank you for your help on this (and once again sorry for my english ...)
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Thank you very much for the detailed test code. We tested this and it seems to work fine. Can you let us know what version of EO.Web.dll and what browser you are using?
|
Rank: Newbie Groups: Member
Joined: 10/1/2014 Posts: 2
|
Hi,
I use the version 11.0.20.2 on Google Chrome (37.0.2062.124)
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
Please try the latest build and see if it works. You can either download EO.Total 2014.0.22 from our download page, or download EO.Web 12.0.11 from nuget. EO.Total 2014.0.22 contains EO.Web 12.0.11.
We did fix some issues related to the delete button in the past. Most recently, we just fixed an issue where deleting an item in the last page may incorrectly reduce the page count. For example, when page size is 10 and total record number is 12, deleting the 12th row would cause the second page to disappear (it should only disappear after deleting 2 rows, not just 1 rows). This problem has been fixed in EO.Web 12.0.11.
Thanks!
|