Jan 13, 2017, 11:50 AM
[CLOSED] Field in GridPanel's field loses its value after change and click in another field
I have an editable GridPanel, I can change the value of an editable field and update it in the database correctly but
after I change the value and click in another field the old value is shown again until I refresh the GridPanel.
The grid code:
after I change the value and click in another field the old value is shown again until I refresh the GridPanel.
The grid code:
<ext:GridPanel
ID="FilesGrid"
runat="server"
Title="Files"
Flex="6"
Region="Center"
>
<Tools>
<ext:Tool Type="Refresh" Handler="#{FilesStore}.reload();" ToolTip="Refresh files" />
</Tools>
<Store>
<ext:Store ID="FilesStore" runat="server" OnLoad="FilesStore_Load" >
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="status" />
<ext:ModelField Name="type" />
<ext:ModelField Name="title" Type="String" />
<ext:ModelField Name="ID" Type="Int"/>
<ext:ModelField Name="version" Type="Float" />
<ext:ModelField Name="ct" />
<ext:ModelField Name="site" Type="String" />
<ext:ModelField Name="country" Type="String" />
<ext:ModelField Name="owner" Type="String" />
<ext:ModelField Name="dm" Type="Date" DateFormat="dd/MM/yyyy" />
<ext:ModelField Name="ed" Type="Date" DateFormat="dd/MM/yyyy" />
<ext:ModelField Name="sdocs" Type="String" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column
runat="server"
Text="Title"
DataIndex="title"
Flex="1">
<Items>
<ext:ComboBox
ID="TitleComboBox"
runat="server"
TrigerAction="All"
QueryMode="Local"
DisplayField="Title"
ValueField="Title">
<Store>
<ext:Store runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="title" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<Listeners>
<Change Handler="applyFilter(this);" Buffer="250" />
</Listeners>
<Plugins>
<ext:ClearButton runat="server" />
</Plugins>
</ext:ComboBox>
</Items>
<Editor>
<Ext:TextField runat="server" AllowBlank="False" />
</Editor>
</ext:Column>
//MORE COLUMNS HERE............
</Columns>
</ColumnModel>
<SelectionModel>
<ext:CellSelectionModel ID="CellSelectionModel1" runat="server" />
</SelectionModel>
<Plugins>
<ext:CellEditing ID="CellEditing1" runat="server">
<Listeners>
<Edit Fn="edit" />
</Listeners>
</ext:CellEditing>
</Plugins>
</ext:GridPanel>
The edit functionvar edit = function (editor, e) {
if (!(e.value === e.originalValue || (Ext.isDate(e.value) && Ext.Date.isEqual(e.value, e.originalValue)))) {
Fields.Edit(e.record.data.ID, e.field, e.originalValue, e.value, e.record.data);
}
};
The Edit function in CodeBehind[DirectMethod(Namespace = "Fields")]
public void Edit(int id, string field, string oldValue, string newValue, object customer) ///////NOT USED
{
string message = "<b>Property:</b> {0}<br /><b>Field:</b> {1}<br /><b>Old Value:</b> {2}<br /><b>New Value:</b> {3}";
// Send Message...
X.Msg.Notify(new NotificationConfig()
{
Title = "Edit Record #" + id.ToString(),
Html = string.Format(message, id, field, oldValue, newValue),
Width = 250,
Height = 150
}).Show();
//this.FilesGrid.GetStore().GetById(id).Commit();
DAL.CDMAdminDataContext dc = new DAL.CDMAdminDataContext();
var result =
(from i in dc.TMFFiles
where i.id == id
select i).First();
switch (field){
case "type":
result.Type = newValue;
dc.SubmitChanges();
break;
case "title":
result.Title = newValue;
dc.SubmitChanges();
break;
case "version":
result.Version = float.Parse(newValue); //check for float number .... 6.1->6.0919912831980
dc.SubmitChanges();
break;
case "owner":
result.Owner = newValue;
dc.SubmitChanges();
break;
}
}
Last edited by fabricio.murta; Feb 25, 2017 at 4:07 AM.
Reason: no user feedback for 7+ days