[CLOSED] Grid store - return IDconfirmation from other than webservice proxy ?

  1. #1

    [CLOSED] Grid store - return IDconfirmation from other than webservice proxy ?

    I have a page that contains multiple gridPanels, formPanels etc. and i save everything in 1 directEvent.

    My problem is that i cannot figure out how to(if even possible) to return an IDconfirmation list to the stores.
    I know how to do it with a webservice proxy that returns an ext.net.response - and i looked through the javascript that handles this on the client, but it only seems to be applied to webservice calls?

    Here's a small example, that i hope illustrates what i would like to accomplish

    <%@ Page Language="VB" %>
    <%@ Import Namespace="System.Web.Services" %>
    <%@ 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">
    <script runat="server">
        
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
            If Not Ext.Net.X.IsAjaxRequest Then
                Me.Store1.DataSource = ArrayData
                Me.Store1.DataBind()
            End If
        End Sub
               
        Private ReadOnly Property ArrayData() As Object()
            Get
                Return New Object() {New Object() {1, "Record 1"}, New Object() {2, "Record 2"}}
            End Get
        End Property
          
        Public Class FooData
            Public ID As Integer
            Public Name As String
            Public Sub New(ID As Integer, Name As String)
                Me.ID = ID
                Me.Name = Name
            End Sub
        End Class
        
        Public Sub Save_click(ByVal sender As Object, ByVal e As DirectEventArgs)
            Dim gridData = e.ExtraParams("gridData").ToString
            If Not String.IsNullOrWhiteSpace(gridData) Then
                Dim dataHandler As New StoreDataHandler(gridData)
                Dim dataList As ChangeRecords(Of FooData) = dataHandler.ObjectData(Of FooData)()
                Dim confirmationList As ConfirmationList = dataHandler.BuildConfirmationList("ID")
                For Each q As FooData In dataList.Deleted
                    'not implemented
                    confirmationList(q.ID).ConfirmRecord()
                Next
                For Each q As FooData In dataList.Updated
                    confirmationList(q.ID).ConfirmRecord()
                Next
                For Each q As FooData In dataList.Created
                    'not implemented
                    confirmationList(q.ID).ConfirmRecord()
                Next
                Dim storeResponse As New StoreResponseData()
                storeResponse.Confirmation = confirmationList
                
                ' ### How to output the confirmation list to the store ?
                
            End If
        End Sub
        
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" Theme="Gray" />
        <ext:GridPanel runat="server" ID="GridPanel1" Height="200" Width="300">
            <Store>
                <ext:Store ID="Store1" UseIdConfirmation="true" RefreshAfterSaving="None" runat="server">
                    <Reader>
                        <ext:ArrayReader IDProperty="ID">
                            <Fields>
                                <ext:RecordField Name="ID" Type="Int" />
                                <ext:RecordField Name="Name" />
                            </Fields>
                        </ext:ArrayReader>
                    </Reader>
                </ext:Store>
            </Store>
            <TopBar>
                <ext:Toolbar runat="server">
                    <Items>
                        <ext:Button runat="server" Text="Save">
                            <DirectEvents>
                                <Click OnEvent="Save_click">
                                    <ExtraParams>
                                        <ext:Parameter Name="gridData" Mode="Raw" Value="'{' + #{Store1}.getChangedData() + '}'"></ext:Parameter>
                                    </ExtraParams>
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                    </Items>
                </ext:Toolbar>
            </TopBar>
            <ColumnModel ID="ColumnModel1" runat="server">
                <Columns>
                    <ext:Column ColumnID="ID" DataIndex="ID" Header="ID" />
                    <ext:Column ColumnID="Name" DataIndex="Name" Header="Name" >
                        <Editor>
                            <ext:TextField runat="server"></ext:TextField>
                        </Editor>
                    </ext:Column>
                </Columns>
            </ColumnModel>
        </ext:GridPanel>
        </form>
    </body>
    </html>
    Last edited by Daniil; Nov 29, 2011 at 7:28 PM. Reason: [CLOSED]
  2. #2
    Hi,

    There is no way to use the confirmation mechanism with a Store's save request.

    Though you don't need that.

    You can commit a record manually:

    Example
    Store1.AddScript("{0}.getById({1}).commit(true);", this.Store.CllientID, "recordId");
    .....
    GridPanel1.Refresh();
    See also
    http://docs.sencha.com/ext-js/3-4/#!...-method-commit
  3. #3
    Hi Daniil,

    Sorry if my example illustrated this poorly -
    But i wanted to use the IDconfirmation mainly when inserting new records to the database.
    Then i would let the IDconfirmation return inserted ID's, and match it up against the temporary ID's, since it works perfectly with the webservice proxy.

    Anyways thanks for the reply - i will build something custom instead.
  4. #4
    Quote Originally Posted by KorsG View Post
    Then i would let the IDconfirmation return inserted ID's, and match it up against the temporary ID's, since it works perfectly with the webservice proxy.
    Yes, it works with an UpdateProxy when a Store's save request occur.

    But, repeat myself, no way to use it out of a Store's save request context.
  5. #5
    To update record id you can use UpdateRecordId method of store
  6. #6
    @Daniil
    Yes, that is understood :-)

    Altough it would have been handy with a store function that could take the IDconfirmation commit array, and process it the same way as the updateproxy
    I often find myself in the scenario where i have multiple grids on the same page, and want to save everything in 1 directevent/method.

    But it's allright, i will create the same functionality manually with the suggestions you provided.

    Thanks.

Similar Threads

  1. Replies: 5
    Last Post: Jun 26, 2012, 8:52 PM
  2. Replies: 5
    Last Post: Jun 10, 2011, 6:35 PM
  3. [CLOSED] set Proxy URL of Store at runtime.
    By farisqadadeh in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Dec 22, 2010, 7:11 AM
  4. How can I get return value webservice?
    By relativ in forum 1.x Help
    Replies: 0
    Last Post: Dec 02, 2009, 4:33 AM
  5. [CLOSED] WebService return date but nothing in grid
    By acrossdev in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: May 26, 2009, 7:30 AM

Tags for this Thread

Posting Permissions