PDA

View Full Version : [CLOSED] Editable grid with server paging with Store warning on dirty = true leads to JavaScript error



anup
Jun 04, 2012, 11:05 PM
I have an editable grid with server side paging. I set the store to warn on dirty. If I edit some grid contents on page 1 and try to go to the next page, I correctly get the Store confirmation about being sure to reload data. If I click yes, I get a JavaScript error:



this.originalLoad is not a function


Here is an example to reproduce it:



<%@ Page Language="C#" %>
<script runat="server">
public class Data
{
public int Id { get; set;}
public string Name { get; set;}

public static List<Data> SampleData
{
get
{
var data = new List<Data>();
for (int i = 0; i < 10; i++)
{
data.Add(new Data { Id = i, Name = "Blah " + i });
}
return data;
}
}
}

protected void Store1_ReadData(object sender, StoreReadDataEventArgs e)
{
int start = e.Start;
int limit = e.Limit;

Paging<Data> data = GetData(start, limit);


e.Total = data.TotalRecords;


Store1.DataSource = data.Data;
Store1.DataBind();
}


private static Paging<Data> GetData(int start, int limit)
{
var data = Data.SampleData;
int totalNumber = data.Count;
int numberToGet = start + limit > totalNumber ? totalNumber - start : limit;


return new Paging<Data>(data.GetRange(start, numberToGet), totalNumber);
}
</script>
<!DOCTYPE html>
<html>
<head runat="server">
<title>Simple Grid - Ext.NET Examples</title>
</head>
<body>
<ext:ResourceManager runat="server" />


<ext:Viewport runat="server" Layout="fit">
<Items>
<ext:GridPanel runat="server" Title="Simple Grid">
<Store>
<ext:Store
Id="Store1"
OnReadData="Store1_ReadData"
runat="server"
PageSize="5"
RemoteSort="true"
WarningOnDirty="true">
<Model>
<ext:Model runat="server" IDProperty="Id">
<Fields>
<ext:ModelField Name="Id" Type="Int" />
<ext:ModelField Name="Name" />
</Fields>
</ext:Model>
</Model>
<Proxy>
<ext:PageProxy />
</Proxy>
</ext:Store>
</Store>
<ColumnModel>
<Columns>
<ext:Column Text="Id" DataIndex="Id" Width="25" />
<ext:Column Text="Name" DataIndex="Name" Flex="1">
<Editor>
<ext:TextField runat="server" />
</Editor>
</ext:Column>
</Columns>
</ColumnModel>
<Plugins>
<ext:CellEditing runat="server" />
</Plugins>
<BottomBar>
<ext:PagingToolbar runat="server" />
</BottomBar>
</ext:GridPanel>
</Items>
</ext:Viewport>
</body>
</html>


Looking in the JavaScript debugger, it looks to me the problem is here:



_load : Ext.data.Store.prototype.load,


load : function (options) {
if (this.warningOnDirty && this.isDirty()) {
Ext.Msg.confirm(
this.dirtyWarningTitle,
this.dirtyWarningText,
function (btn, text) {
if (btn == "yes") {
this.originalLoad(options); // <-- this is the line failing
}
},
this
);
return this;
}
return this._load(options);
},


I've not studied the file fully, but just looking at the above snippet, I suspect that instead of calling this.originalLoad(options); it should be using this._load(options)?

Thanks!

Daniil
Jun 05, 2012, 12:59 PM
Hi,

Thanks for the report. Fixed in SVN, revision #4071.

anup
Jun 06, 2012, 8:27 PM
Thanks for the fix. Looks good; you can mark as closed.