Nov 07, 2018, 2:01 PM
Ext.Net MVC store.getChangedRecords not giving newly inserted rows
hi,
I'm trying to store batch update. when I insert a new record to store I can see the new record with getAllRange method and the newly inserted record is phantom = true crudstate is "C" but when I tried to getChangedData the inserted records does not seen in the results. what is the my mistake ? can you help me?
view
---------------
----------------
------------------
I'm trying to store batch update. when I insert a new record to store I can see the new record with getAllRange method and the newly inserted record is phantom = true crudstate is "C" but when I tried to getChangedData the inserted records does not seen in the results. what is the my mistake ? can you help me?
view
---------------
@using resources = ViewReources.Code
@model IEnumerable<BLL.Db.KOD_TABLE_YDK>
@{
Layout = "~/Views/Shared/_LifeInLayout.cshtml";
var X = Html.X();
}
@section scripts{
<script type="text/javascript">
var validateCode = function () {
var valid = App.fpCode.getForm().isValid();
App.btnSaveCode.setDisabled(!valid);
}
var getFilter = function () {
App.gpCode.getStore().reload();
}
var clearCode = function () {
formReset(App.fpCode);
App.rsmCode.deselectAll();
App.cboCodeAim.setDisabled(false);
App.txtCode.setDisabled(false);
App.txtValidDate.allowBlank=true;
validateCode();
}
var updateCode = function (fp) {
if (!fp.getForm().getValues().SQ_KOD_ID) {
App.gpCode.store.insert(0, new KodTable(fp.getForm().getValues()));
fp.getForm().reset();
}
else {
if (!fp.getForm().isValid()) {
Ext.net.Notification.show({
iconCls: "icon-exclamation",
html: "Form is invalid",
title: "Error"
});
return false;
}
fp.getForm().updateRecord();
}
clearCode();
App.cboCodeAim.focus();
}
var loadCode = function (grid, selectedData) {
if (grid.getSelected().length > 0) {
App.fpCode.getForm().loadRecord(selectedData);
}
}
var saveForm = function () {
var recs = [];
var records = App.gpCode.getStore().getAllRange();
for (var i = 0; i < records.length; i++) {
var rec = records[i];
if (rec.dirty == true) {
recs.push(rec);
//Save data
}
}
return recs;
}
var storeLoader = function (a,b,c) {
App.gpCode.getStore().proxy.extraParams.filterCodeAim = App.cboFilterCodeAim.getValue();
App.gpCode.getStore().proxy.extraParams.filterCode = App.cboFilterCode.getValue();
App.gpCode.getStore().proxy.extraParams.filterValueCode = App.txtFilterValueCode.getValue();
App.gpCode.getStore().proxy.extraParams.filterDescription = App.txtFilterDescription.getValue();
App.gpCode.getStore().proxy.extraParams.filterValidDate = App.txtFilterValidDate.getValue();
}
</script>
}
@section pageBody{
@(X.Store()
.ID("StoreCodeAimCombo")
.Model(
X.Model()
.IDProperty("")
.Fields(
X.ModelField()
.Name("Key"),
X.ModelField()
.Name("Value")
)
)
.Proxy(
X.AjaxProxy()
.Url(Url.Action("GetCodeAimComboBox"))
.Reader(Html.X().JsonReader().RootProperty("data"))
)
)
@(X.Container()
.Layout(LayoutType.Fit)
.Items(
X.FormPanel()
.ID("formPanelContent")
.BodyPadding(5)
.Border(false)
.Layout(LayoutType.VBox)
.TopBar((System.Action<Ext.Net.ToolbarCollection>)(items =>
{
items.Add(Html.X().Toolbar().Items(buttons =>
{
buttons.Add(Html.X().Button()
.ID("btnNew")
.Text(resources.Index.btnNew_text)
.Icon(Icon.PageWhite)
);
buttons.Add(Html.X().Button()
.ID("btnSave")
.Icon(Icon.Disk)
.Text(resources.Index.btnSave_text)
.DirectEvents(de =>
{
de.Click.Url = Url.Action("SaveChanges");
de.Click.ExtraParams.Add(new Parameter
{
Name = "data",
Value = "App.gpCode.store.getChangedData()",
Mode = ParameterMode.Raw,
Encode = true
});
}
)
);
}));
}))
.Items(
X.FormPanel()
.ID("fpFilter")
.BodyPadding(5)
.Layout(LayoutType.HBox)
.MarginSpec("0 0 5 0")
.Frame(true)
.Height(130)
.Width(900)
.Items(
X.Container()
.Layout(LayoutType.Anchor)
.MarginSpec("0 5 0 0")
.Flex(1)
.Items(
X.ComboBox()
.ID("cboFilterCodeAim")
.QueryMode(DataLoadMode.Local)
.EnableRegEx(true)
.AnchorHorizontal("95%")
.StoreID("StoreCodeAimCombo")
.DisplayField("Value")
.ValueField("Key")
.FieldLabel("Kod Amaç")
.AutoDataBind(true)
.Listeners(ls =>
ls.Select.Handler = "App.cboFilterCode.clearValue(); App.cboFilterCode.getStore().load()"
),
X.ComboBox()
.ID("cboFilterCode")
.TypeAhead(true)
.QueryMode(DataLoadMode.Local)
.ForceSelection(true)
.TriggerAction(TriggerAction.All)
.DisplayField("Value")
.ValueField("Key")
.FieldLabel("Kod")
.AnchorHorizontal("95%")
.Store(X.Store()
.AutoLoad(false)
.Model(X.Model()
.IDProperty("Id")
.Fields(
new ModelField("Key", ModelFieldType.String) { Mapping = "Key" },
new ModelField("Value", ModelFieldType.String) { Mapping = "Value" }
)
)
.Proxy(X.AjaxProxy()
.Url(Url.Action("GetFilterCode"))
.Reader(X.JsonReader().RootProperty("data"))
)
.Parameters(ps =>
ps.Add(new StoreParameter("aimCode", "App.cboFilterCodeAim.getValue()", ParameterMode.Raw))
)
),
X.TextField()
.ID("txtFilterValueCode")
.FieldLabel("DeÄŸer Kod")
.AnchorHorizontal("95%")
),
X.Container()
.Layout(LayoutType.Anchor)
.MarginSpec("0 5 0 0")
.Flex(1)
.Items(
X.TextField()
.ID("txtFilterDescription")
.FieldLabel("Açıklama")
.AnchorHorizontal("95%"),
X.DateField()
.ID("txtFilterValidDate")
.FieldLabel("Geçerlilik Tarihi")
.AnchorHorizontal("95%")
)
)
.Buttons(
X.Button()
.Text("Filtrele")
.Icon(Icon.Find)
.ID("btnFilterBySelection")
.Listeners(l => { l.Click.Handler = "getFilter();"; })
)
,
X.GridPanel()
.ID("gpCode")
.Width(900)
.Height(500)
.AutoScroll(true)
.Scroll(ScrollMode.Both)
.MinHeight(350)
.Store(
X.StoreForModel()
.ID("StoreCode")
.AutoLoad(false)
.BatchUpdateMode(BatchUpdateMode.Complete)
.Proxy(X.AjaxProxy()
.Url(Url.Action("FilterCodesPaging"))
.Reader(X.JsonReader().RootProperty("data"))
.ExtraParams(
p => {
p.Add(new Parameter("filterCodeAim", "''", ParameterMode.Raw));
p.Add(new Parameter("filterCode", "''", ParameterMode.Raw));
p.Add(new Parameter("filterValueCode", "''", ParameterMode.Raw));
p.Add(new Parameter("filterDescription", "''", ParameterMode.Raw));
p.Add(new Parameter("filterValidDate", "''", ParameterMode.Raw));
}
)
)
.Listeners(l => { l.BeforeLoad.Fn = "storeLoader"; })
)
.ColumnModel(
X.Column().Text("Sıra No").DataIndex("SIRA_NO").Width(50),
X.Column().Text("Kod Amaç").DataIndex("KOD_AMAC").Width(65),
X.Column().Text("Kod").DataIndex("KOD").Width(50),
X.Column().Text("DeÄŸer Kod").DataIndex("DEGER_KOD").Width(70),
X.Column().Text("Ãœst Kod").DataIndex("UST_KOD").Width(70),
X.Column().Text("Ãœst DeÄŸ.").DataIndex("UST_DEG").Width(70),
X.Column().Text("Açıklama").DataIndex("ACIKLAMA").Width(150),
X.Column().Text("Muaf.Oran").DataIndex("MUAF_ORAN").Width(70),
X.Column().Text("Muaf Matrah").DataIndex("MUAF_MATRAH").Width(70),
X.DateColumn().Text("Geç. Tar").DataIndex("GECERLILIK_TARIH").Width(70).Format("d.m.Y"),
X.Column().Text("Oran").DataIndex("ORAN").Width(70),
X.Column().Text("Matrah").DataIndex("MATRAH").Width(70),
X.Column().Text("Değ.Açıklama").DataIndex("DEGER_ACIKLAMA").Width(70),
X.Column().Text("Muaf Asg.").DataIndex("MUAF_ASGARI").Width(70),
X.Column().Text("Muaf Azami").DataIndex("MUAF_AZAMI_MAKTU").Width(70),
X.Column().Text("Döviz").DataIndex("DOVIZ").Width(70),
X.Column().ID("Id").Text("KodId").DataIndex("SQ_KOD_ID").Width(70).Hidden(true)
.Renderer("return record.phantom ? '' : value;")
)
.SelectionModel(
X.RowSelectionModel()
.ID("rsmCode")
.Mode(SelectionMode.Single)
.AllowDeselect(true)
.Listeners(
l => l.Select.Fn = "loadCode"
)
)
.BottomBar(
X.PagingToolbar()
.DisplayInfo(true)
)
,
X.FormPanel()
.ID("fpCode")
.BodyPadding(5)
.Width(900)
.Height(210)
.Frame(true)
.Layout(LayoutType.HBox)
.Items(
X.Container()
.Layout(LayoutType.Anchor)
.MarginSpec("0 5 0 0")
.Flex(1)
.Items(
X.HiddenFor(m=>m.FirstOrDefault().SQ_KOD_ID)
.ID("hdnCodeId"),
X.ComboBox()
.ID("cboCodeAim")
.QueryMode(DataLoadMode.Local)
.EnableRegEx(true)
.AnchorHorizontal("95%")
.DisplayField("Value")
.ValueField("Key")
.FieldLabel("Kod Amaç")
.AutoDataBind(true)
.AllowBlank(false)
.Name("KOD_AMAC")
.Store(X.Store()
.AutoLoad(true)
.Model(X.Model()
.IDProperty("Id")
.Fields(
new ModelField("Key", ModelFieldType.String) { Mapping = "Key" },
new ModelField("Value", ModelFieldType.String) { Mapping = "Value" }
)
)
.Proxy(X.AjaxProxy()
.Url(Url.Action("GetCodeAimComboBox"))
.Reader(X.JsonReader().RootProperty("data"))
)
),
X.TextFieldFor(m => m.FirstOrDefault().KOD)
.ID("txtCode")
.FieldLabel("Kod")
.AllowBlank(false),
X.TextFieldFor(m => m.FirstOrDefault().DEGER_KOD)
.ID("txtValueCode")
.FieldLabel("DeÄŸer Kod")
.AllowBlank(true),
X.TextFieldFor(m => m.FirstOrDefault().UST_KOD)
.ID("txtParentCode")
.FieldLabel("Ãœst Kod")
.AllowBlank(true),
X.TextFieldFor(m => m.FirstOrDefault().UST_DEG)
.ID("txtParentValue")
.FieldLabel("Ãœst DeÄŸ")
.AllowBlank(true)
)
,
X.Container()
.Layout(LayoutType.Anchor)
.MarginSpec("0 5 0 0")
.Flex(1)
.Items(
X.TextFieldFor(m => m.FirstOrDefault().ACIKLAMA)
.ID("txtDescription")
.FieldLabel("Açıklama")
.AllowBlank(false),
X.NumberFieldFor(m => m.FirstOrDefault().MUAF_ORAN)
.ID("txtExemptRate")
.FieldLabel("Muaf. Oran")
.AllowBlank(true)
.HideTrigger(true),
X.NumberFieldFor(m => m.FirstOrDefault().MUAF_MATRAH)
.ID("txtExemptBasis")
.FieldLabel("Muaf. Matrah")
.AllowBlank(true)
.HideTrigger(true),
X.DateFieldFor(m => m.FirstOrDefault().GECERLILIK_TARIH)
.ID("txtValidDate")
.FieldLabel("Geç.Tarih")
.AllowBlank(false)
.Format("d.m.Y"),
X.ComboBoxFor(m => m.FirstOrDefault().DEG_AMAC)
.ID("cboValueAim")
.TypeAhead(true)
.QueryMode(DataLoadMode.Local)
.ForceSelection(true)
.TriggerAction(TriggerAction.All)
.DisplayField("Value")
.ValueField("Key")
.FieldLabel("Değ. Amaç")
.AnchorHorizontal("95%")
.Store(X.Store()
.AutoLoad(true)
.Model(X.Model()
.IDProperty("Id")
.Fields(
new ModelField("Key", ModelFieldType.String) { Mapping = "Key" },
new ModelField("Value", ModelFieldType.String) { Mapping = "Value" }
)
)
.Proxy(X.AjaxProxy()
.Url(Url.Action("GetValueAim"))
.Reader(X.JsonReader().RootProperty("data"))
)
),
X.NumberFieldFor(m => m.FirstOrDefault().ORAN)
.ID("txtRate")
.FieldLabel("Oran")
.AllowBlank(true)
.HideTrigger(true)
),
X.Container()
.Layout(LayoutType.Anchor)
.MarginSpec("0 5 0 0")
.Flex(1)
.Items(
X.TextFieldFor(m => m.FirstOrDefault().MATRAH)
.ID("txtBasis")
.FieldLabel("Matrah")
.AllowBlank(true),
X.TextFieldFor(m => m.FirstOrDefault().DEGER_ACIKLAMA)
.ID("txtValueDescription")
.FieldLabel("Değer Açıklama")
.AllowBlank(true),
X.NumberFieldFor(m => m.FirstOrDefault().SIRA_NO)
.ID("txtQueueNumber")
.FieldLabel("Sıra No")
.AllowBlank(true)
.HideTrigger(true),
X.NumberFieldFor(m => m.FirstOrDefault().MUAF_ASGARI)
.ID("txtExemptAtLeast")
.FieldLabel("Muaf Asgari")
.AllowBlank(true)
.HideTrigger(true),
X.NumberFieldFor(m => m.FirstOrDefault().MUAF_AZAMI_MAKTU)
.ID("txtMaxFixedExempt")
.FieldLabel("Muaf Azm. Maktu")
.AllowBlank(true)
.HideTrigger(true),
X.TextFieldFor(m => m.FirstOrDefault().DOVIZ)
.ID("txtExchange")
.FieldLabel("Döviz")
.AllowBlank(true)
)
)
.Buttons(
X.Button()
.ID("btnSaveCode")
.Text("Ekle Güncelle")
.OnClientClick("updateCode(App.fpCode)"),
X.Button()
.ID("btnNewCode")
.Text("Yeni")
.OnClientClick("clearCode();")
)
.Listeners(
l =>
{
l.ValidityChange.Handler = "validateCode()";
l.AfterRender.Handler = "validateCode()";
}
)
)
)
)
}
Controller----------------
public ActionResult SaveChanges(StoreDataHandler handler)
{
ChangeRecords<KOD_TABLE_YDK> codes = handler.BatchObjectData<KOD_TABLE_YDK>();
var store = this.GetCmp<Store>("StoreCode");
return this.Direct();
}
Model------------------
namespace BLL.Db
{
using Ext.Net.MVC;
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
[Model(Name = "KodTable", ClientIdProperty = "SQ_KOD_ID")]
[Table("GNL.KOD_TABLE_YDK")]
public partial class KOD_TABLE_YDK
{
public byte? SIRKET_KOD { get; set; }
[StringLength(2)]
public string KOD_AMAC { get; set; }
[StringLength(3)]
public string KOD { get; set; }
[StringLength(3)]
public string DEGER_KOD { get; set; }
[StringLength(3)]
public string UST_KOD { get; set; }
[StringLength(3)]
public string UST_DEG { get; set; }
[StringLength(200)]
public string ACIKLAMA { get; set; }
public decimal? MUAF_ORAN { get; set; }
public short? MUAF_MATRAH { get; set; }
public DateTime? GECERLILIK_TARIH { get; set; }
[StringLength(3)]
public string OLD_DOVIZ { get; set; }
public decimal? OLD_MUAF_ASGARI { get; set; }
public decimal? OLD_MUAF_AZAMI_MAKTU { get; set; }
[StringLength(2)]
public string DEG_AMAC { get; set; }
public decimal? ORAN { get; set; }
public short? MATRAH { get; set; }
[StringLength(4000)]
public string DEGER_ACIKLAMA { get; set; }
public short? SIRA_NO { get; set; }
[StringLength(12)]
public string OP_ID { get; set; }
public DateTime? TARIH { get; set; }
public decimal? MUAF_ASGARI { get; set; }
public decimal? MUAF_AZAMI_MAKTU { get; set; }
[StringLength(3)]
public string DOVIZ { get; set; }
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
[ModelField(IDProperty = true, UseNull = true)]
[Field(Ignore = true)]
public int? SQ_KOD_ID { get; set; }
[Required]
[StringLength(20)]
public string CH_CREATOR { get; set; }
public DateTime? DT_CREATED { get; set; }
[StringLength(20)]
public string CH_MODIFIER { get; set; }
public DateTime? DT_MODIFIED { get; set; }
}
}