Aug 11, 2015, 3:12 AM
[CLOSED] Batch Update with MVC
I see a BatchUpdate (non mvc) example. i see a Save WebServices example (closer to mvc).
However, i dont see a Batch Save example with MVC (persist happens in the controller).
From what i understand from docs, to use the Batch save, we must use a DirectEvent. I would have expected to use a SyncParameter with Store.getChangedData() but that didnt work. Only works with the DirectEvent.
I need to use the Batch since all our code is based on the 1.7 stuff and we need the transactional support of all/nothing.
That being said, how can update the store to remove the dirty flags from the controller? I am on MVC in a controller so i have no access to the store object. I would need to store the data, send it back and then update it manually? Is there a better solution?
I thought the ConfirmationList was a great solution. In my sample below, i have a standard grid that has a batch save to a controller. saveFunc was the original code but that doesnt seem to work anymore since the data param must be explicit now.
Also, what is the purpose of the API Sync if i submit via a DirectEvent button?
/Z
However, i dont see a Batch Save example with MVC (persist happens in the controller).
From what i understand from docs, to use the Batch save, we must use a DirectEvent. I would have expected to use a SyncParameter with Store.getChangedData() but that didnt work. Only works with the DirectEvent.
I need to use the Batch since all our code is based on the 1.7 stuff and we need the transactional support of all/nothing.
That being said, how can update the store to remove the dirty flags from the controller? I am on MVC in a controller so i have no access to the store object. I would need to store the data, send it back and then update it manually? Is there a better solution?
I thought the ConfirmationList was a great solution. In my sample below, i have a standard grid that has a batch save to a controller. saveFunc was the original code but that doesnt seem to work anymore since the data param must be explicit now.
Also, what is the purpose of the API Sync if i submit via a DirectEvent button?
<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!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 id="Head1" runat="server">
<title>Employee Profile</title>
<script type="text/javascript">
var saveFunc = function (obj) {
Ext.net.Mask.show();
var grid = Ext.getCmp("GridPanel2");
grid.getStore().sync();
};
</script>
</head>
<body>
<form id="Form4" runat="server">
<ext:ResourceManager ID="ResourceManager" runat="server">
<Listeners>
<BeforeAjaxRequest Handler="Ext.net.Mask.show();" />
<AjaxRequestComplete Handler="Ext.net.Mask.hide();" />
<AjaxRequestException Handler="Ext.net.Mask.hide();" />
</Listeners>
</ext:ResourceManager>
<ext:Viewport ID="Viewport1" runat="server" AutoScroll="True" Layout="FitLayout">
<Items>
<ext:GridPanel
ID="GridPanel2"
runat="server"
Title="Summary"
AutoScroll="true">
<Store>
<ext:Store ID="Store3"
runat="server"
WarningOnDirty="false"
RemoteSort="false">
<Proxy>
<ext:AjaxProxy Url="/ta/XXX/AAA/" >
<API Sync="/ta/XXX/BBB/" />
<Reader>
<ext:JsonReader IDProperty="id" RootProperty="data" TotalProperty="total" />
</Reader>
<Writer>
<ext:JsonWriter Encode="true" RootProperty="data" />
</Writer>
</ext:AjaxProxy>
</Proxy>
<Parameters>
<ext:StoreParameter Name="test" Value="false" Mode="Value" />
</Parameters>
<Model>
<ext:Model ID="Model1" runat="server">
<Fields>
<ext:ModelField Name="id" Type="Int"/>
<ext:ModelField Name="accountAmount" Type="Float" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel ID="ColumnModel7" runat="server">
<Columns>
<ext:Column ID="Column2" runat="server" Text="id" Width="90" DataIndex="id" />
<ext:Column ID="Column3" runat="server" Text="Actual" Width="140" DataIndex="accountAmount">
<Renderer Fn="change" />
<Editor>
<ext:TextField ID="txtData" runat="server">
</ext:TextField>
</Editor>
</ext:Column>
</Columns>
</ColumnModel>
<Plugins>
<ext:CellEditing ID="CellEditing1" ClicksToEdit="1" runat="server" >
</ext:CellEditing>
</Plugins>
<SelectionModel>
<ext:RowSelectionModel ID="RowSelection5" runat="server" Mode="Single"/>
</SelectionModel>
<BottomBar>
<ext:Toolbar ID="ToolbarUpdate" runat="server">
<Items>
<ext:Toolbar ID="ToolbarButtons" runat="server">
<Items>
<ext:Button ID="Button1" runat="server" Text="Sync" Icon="Disk">
<DirectEvents>
<Click
Url="/ta/XXX/YYY"
Timeout="60000"
CleanRequest="true"
Before="return #{Store3}.isDirty();"
Method="POST"
Failure="Ext.Msg.show({
title: 'Error',
msg: result.message || result.errorMessage,
buttons: Ext.Msg.OK,
icon: Ext.MessageBox.ERROR
});">
<EventMask MinDelay="250" />
<ExtraParams>
<ext:Parameter Name="data" Value="#{Store3}.getChangedData()" Mode="Raw" Encode="true" />
</ExtraParams>
</Click>
</DirectEvents>
</ext:Button>
<ext:Button ID="ButtonsaveFunc" runat="server" Text="Save" Icon="Disk">
<Listeners>
<Click Handler="saveFunc(this);" />
</Listeners>
</ext:Button>
</Items>
</ext:Toolbar>
</Items>
</ext:Toolbar>
</BottomBar>
<View>
<ext:GridView ID="GridView1" runat="server" StripeRows="true" />
</View>
</ext:GridPanel>
</Items>
</ext:Viewport>
</form>
</body>
</html>
Thanks,/Z
Last edited by Daniil; Aug 17, 2015 at 6:23 PM.
Reason: [CLOSED]