Jan 12, 2012, 10:55 PM
Example of using a RESTful Store with something other than a GridPanel
I've got a Form hooked up to a Store with a RestAPI setup. I am having a problem getting a button to call the Update method. I keep getting a "Object [object Object] has no method 'update'" error. The initial GET REST method that loads the form works fine.
Here's are my code snippets
Any help on this would be appreciated... Thanks!
Here's are my code snippets
function updateOrder() {
alert("updating");
dsOrder.update();
}
<ext:Store ID="dsOrder" runat="server" AutoLoad="true" SerializationMode="Complex"
AutoSave="true" Restful="true">
<Proxy>
<ext:HttpProxy>
<RestAPI ReadUrl="/Order/Get"
UpdateUrl="/Order/Update" CreateUrl="/RestDemo/Create"
DestroyUrl="/RestDemo/Destroy" />
</ext:HttpProxy>
</Proxy>
<Reader>
<ext:JsonReader IDProperty="OrderNumber" Root="data">
<Fields>
<ext:RecordField Name="OrderID" />
<ext:RecordField Name="OrderNumber" />
<ext:RecordField Name="UserName" />
<ext:RecordField Name="DateCreated" Type="Date" />
<ext:RecordField Name="OrderStatusID" />
<ext:RecordField Name="Items" IsComplex="true" />
<ext:RecordField Name="ShippingAddress">
<Convert Fn="convertShippingVals" />
</ext:RecordField>
<ext:RecordField Name="ShippingMethodID">
<Convert Fn="convertShipMethodToText" />
</ext:RecordField>
<ext:RecordField Name="ShippingMethodText" />
<ext:RecordField Name="ShippingAmount" />
<ext:RecordField Name="DateShipped" Type="Date">
<Convert Fn="formatDateShipped" />
</ext:RecordField>
<ext:RecordField Name="DateShippedText" />
<ext:RecordField Name="EstimatedDelivery" Type="Date" />
<ext:RecordField Name="TrackingNumber" />
<ext:RecordField Name="FirstName" />
<ext:RecordField Name="LastName" />
<ext:RecordField Name="Street1" />
<ext:RecordField Name="Street2" />
<ext:RecordField Name="City" />
<ext:RecordField Name="StateOrProvince" />
<ext:RecordField Name="Zip" />
<ext:RecordField Name="Country" />
</Fields>
</ext:JsonReader>
</Reader>
<BaseParams>
<ext:Parameter Name="start" Value="0" Mode="Raw" />
<ext:Parameter Name="ordernum" Value="#{txtOID}.getValue()" Mode="Raw" />
</BaseParams>
<Listeners>
<Load Handler="OrderDetails.body.unmask(); if(records.length > 0) { fillOrder(records[0])}else { #{OrderCommonInformation}.form.reset(); #{ShippingInformationForm}.form.reset(); this.removeAll(); }" />
</Listeners>
</ext:Store>
<ext:Button ID="btnSave" runat="server" Icon="Disk" TabIndex="119" Text="Save Incentive">
<Listeners>
<Click Handler="updateOrder();" />
</Listeners>
</ext:Button>
I cannot seem to find any example of someone else using REST methods for store that is bound to form elements. Is there anyone out there that can provide me with a simple example of how to call the update REST method with a button?Any help on this would be appreciated... Thanks!