Jul 08, 2014, 11:04 AM
[CLOSED] Store issue in new version
Hi,
Recently I converted to new ext.net version from 2.1 to 2.5. but I got one issue while using getChangedData() method on store.
Here I have attached minified sample.
First click on "Add In Grid" button to add new record and then click on "Save" button, on save button code, I am not getting added records count, can you suggest me what is wrong with this?
Recently I converted to new ext.net version from 2.1 to 2.5. but I got one issue while using getChangedData() method on store.
Here I have attached minified sample.
First click on "Add In Grid" button to add new record and then click on "Save" button, on save button code, I am not getting added records count, can you suggest me what is wrong with this?
<%@ Page Title="Home Page" Language="C#" %>
<ext:ResourceManager ID="Res1" runat="server"></ext:ResourceManager>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (!X.IsAjaxRequest)
{
List<BloodGroup> lstBloodGroup = new List<BloodGroup>();
this.StoreBloodGroup.DataSource = lstBloodGroup.ToList();
this.StoreBloodGroup.DataBind();
}
}
catch (Exception ex)
{
throw (ex);
}
}
protected void Save_Click(object sender, DirectEventArgs e)
{
try
{
ChangeRecords<BloodGroup> bloodgroups = new StoreDataHandler(e.ExtraParams["BloodGroupData"]).BatchObjectData<BloodGroup>();
if (bloodgroups.Deleted.Count > 0 || bloodgroups.Created.Count > 0 || bloodgroups.Updated.Count > 0)
{
string message = "";
message = "Inserted Records : " + bloodgroups.Created.Count.ToString();
message += "Updated Records : " + bloodgroups.Updated.Count.ToString();
message += "Deleted Records : " + bloodgroups.Deleted.Count.ToString();
new MessageBox().Show(new MessageBoxConfig()
{
Title = " ",
Message = message,
Buttons = MessageBox.Button.OK,
});
}
else
{
new MessageBox().Show(new MessageBoxConfig()
{
Title = " ",
Message = "No Records to be saved!",
Buttons = MessageBox.Button.OK,
});
}
}
catch (Exception ex)
{
throw (ex);
}
}
protected void btnAddInGrid_Click(object sender, DirectEventArgs e)
{
try
{
BloodGroup bg = new BloodGroup();
bg.BloodGrpName = "abc";
this.StoreBloodGroup.Add(bg);
}
catch (Exception ex)
{
throw (ex);
}
}
public class BloodGroup
{
public long BloodGrpID { get; set; }
public string BloodGrpName { get; set; }
}
</script>
<ext:GridPanel runat="server" ID="GridBloodGroup"
IDMode="Static" ColumnLines="true" Height="600">
<Store>
<ext:Store runat="server" ID="StoreBloodGroup" IDMode="Static">
<Model>
<ext:Model runat="server" ID="ModelBloodGroup" IDProperty="BloodGrpID">
<Fields>
<ext:ModelField Name="BloodGrpID" Type="Int" />
<ext:ModelField Name="BloodGrpName" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel>
<Columns>
<ext:Column ID="Column1" runat="server" DataIndex="BloodGrpID" Text="Blood Group ID" Sortable="true" Width="110">
<Editor>
<ext:TextField ID="TextField1" runat="server" AllowBlank="false">
</ext:TextField>
</Editor>
</ext:Column>
<ext:Column ID="colBloodGroupName" runat="server" DataIndex="BloodGrpName" Text="Blood Group Name" Sortable="true" Hideable="true" Width="110">
<Editor>
<ext:TextField ID="txtBloodGroupName" runat="server" AllowBlank="false">
</ext:TextField>
</Editor>
</ext:Column>
</Columns>
</ColumnModel>
<Plugins>
<ext:CellEditing ID="CellEditing1" runat="server" ClicksToEdit="1">
</ext:CellEditing>
</Plugins>
<Buttons>
<ext:Button ID="btnAddInGrid" runat="server" IDMode="Static" Icon="Add" Text="Add In Grid">
<DirectEvents>
<Click OnEvent="btnAddInGrid_Click" />
</DirectEvents>
</ext:Button>
<ext:Button ID="btnSave" runat="server" Text="Save" Icon="Disk">
<DirectEvents>
<Click OnEvent="Save_Click">
<ExtraParams>
<ext:Parameter Name="BloodGroupData" Value="App.StoreBloodGroup.getChangedData({skipIdForNewRecords : true})" Mode="Raw" Encode="true" />
</ExtraParams>
</Click>
</DirectEvents>
</ext:Button>
</Buttons>
</ext:GridPanel>
Last edited by Daniil; Jul 12, 2014 at 9:05 AM.
Reason: [CLOSED]