PDA

View Full Version : [CLOSED] Flushing data to formĀ“s store



RCN
May 04, 2012, 1:31 PM
Hi folks, i would like to know which is the best way to update the form“s store when i edit a field, in other words, "flush" the fields to the store.

Daniil
May 04, 2012, 10:13 PM
Hi,

Hope I correctly understand the requirement. You should use the BasicForm updateRecord method.
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.form.Basic-method-updateRecord

Example

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
this.Store1.DataSource = new object[]
{
new object[] { "test1", "test2", "test3" }
};
this.Store1.DataBind();
}
}
</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>Ext.NET v2 Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<ext:Store ID="Store1" runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="test1" />
<ext:ModelField Name="test2" />
<ext:ModelField Name="test3" />
</Fields>
</ext:Model>
</Model>
</ext:Store>

<ext:FormPanel ID="FormPanel1" runat="server">
<Items>
<ext:TextField runat="server" Name="test1" />
<ext:TextField runat="server" Name="test2" />
<ext:TextField runat="server" Name="test3" />
</Items>
</ext:FormPanel>

<ext:Button runat="server" Text="Load record from Store to FormPanel">
<Listeners>
<Click Handler="#{FormPanel1}.loadRecord(#{Store1}.getAt(0));" />
</Listeners>
</ext:Button>

<ext:Button runat="server" Text="Save record from FormPanel to Store">
<Listeners>
<Click Handler="#{FormPanel1}.getForm().updateRecord();" />
</Listeners>
</ext:Button>

<ext:Button runat="server" Text="Show record of the Store">
<Listeners>
<Click Handler="alert(Ext.encode(#{Store1}.getAt(0).data));" />
</Listeners>
</ext:Button>
</form>
</body>
</html>