Nov 04, 2010, 5:16 PM
[CLOSED] Store loadData() wierd error.
Hi all,
I have an issue with the store.loadData() function.
Firebug, with ScriptMode="Debug", shows me the following error:
I double checked and it is some code in the JsonReader.js
Hera an example on how i use the loadData() function.
The example works fine and i wasn't able to reproduce the bug... so i can't really understand what's wrong with my code! :mad:
I'm looking for some suggestions.
I have an issue with the store.loadData() function.
Firebug, with ScriptMode="Debug", shows me the following error:
root is undefined
var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
Hera an example on how i use the loadData() function.
The example works fine and i wasn't able to reproduce the bug... so i can't really understand what's wrong with my code! :mad:
I'm looking for some suggestions.
<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
protected void Button_Click(object sender, DirectEventArgs e)
{
X.Msg.Prompt("Name", "Please enter a name:", new JFunction { Fn = "add" }).Show();
}
private static int counter = 0;
[DirectMethod]
public Data Add(Data data)
{
data.Id = counter++;
return data;
}
public class Data
{
public int Id { get; set; }
public string Name { get; set; }
}
</script>
<!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>User FormPanel</title>
<ext:ResourcePlaceHolder runat="server" Mode="Script" />
<script type="text/javascript">
var add = function (btn, name) {
var grid = GridPanel;
var record = new grid.store.recordType({
Name: name
});
var addRecord = function (data) {
grid.store.loadData(data, true);
};
Ext.net.DirectMethods.Add(record.data, {
success: addRecord,
eventMask: {
showMask: true,
msg: "Updating ..."
}
});
}
</script>
</head>
<body>
<ext:ResourceManager ID="ResourceManager" runat="server" />
<ext:Store
runat="server"
ID="Store"
AutoLoad="false"
RefreshAfterSaving="Always">
<Reader>
<ext:JsonReader IDProperty="Id">
<Fields>
<ext:RecordField Name="Id" Type="Int" />
<ext:RecordField Name="Name" Type="String"/>
</Fields>
</ext:JsonReader>
</Reader>
<SortInfo Field="Id" Direction="ASC" />
</ext:Store>
<ext:GridPanel
runat="server"
ID="GridPanel"
StoreID="Store"
Title="Table"
Icon="Table"
Frame="true"
AutoHeight="true"
Width="400">
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:Column Header="ID" DataIndex="Id" ColumnID="id" />
<ext:Column Header="Name" DataIndex="Name" ColumnID="name" />
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel runat="server" />
</SelectionModel>
<Buttons>
<ext:Button runat="server" Text="Add" Icon="Add">
<DirectEvents>
<Click OnEvent="Button_Click" />
</DirectEvents>
</ext:Button>
</Buttons>
</ext:GridPanel>
</body>
</html>
Last edited by Daniil; Nov 12, 2010 at 7:36 AM.
Reason: Marked as [CLOSED]. No more information was provided.