[CLOSED] Using Coolite Store without ASP.NET Data Sources

  1. #1

    [CLOSED] Using Coolite Store without ASP.NET Data Sources

    *I was trying to customize the following Coolite example (updating DataSources) to fit my situation:
    https://examples1.ext.net/#/GridPane...SqlDataSource/

    I was mainly interested in the UI part. I dont normally use ASP.NET data sources because of multi-tier application architectures I work with where those Sources dont fit-in exactly, and also because of their Reflection overhead.

    So, basically I was trying to use the cited example's concept to add, modify & delete data on a single page.

    As I am not using the data sources, I handled the Store's BeforeRecordInserted & AfterRecordInserted events. I have set the Store's UseIdConfirmation to true.
    I am able to insert data successfully in the BeforeRecordInserted event. However, as e.Confirmation parameter is Null.

    So, I waited for the AfterRecordInserted event. To my surprise, even there e.Confirmation was null. And eventually I get the following error even after the record was successfully inserted:

    "Reason: The confirmation list is absent"

    Is Store designed to work only with ASP.NET Data Sources?? Is there any other work-around?? I have seen examples of using Arrays & Lists. But the updation example has been demonstrated only for SqlDataSource.
  2. #2

    RE: [CLOSED] Using Coolite Store without ASP.NET Data Sources

    Hi r_honey,

    If you use confirmation then you must define ReaderID in Store Reader.
    Please check ReaderID and let me know if you have ReaderID already


  3. #3

    RE: [CLOSED] Using Coolite Store without ASP.NET Data Sources

    Here's my code for the Store

        <ext:Store runat="server" ID="store1" RefreshAfterSaving="Always" UseIdConfirmation="true">
            <Reader>
                <ext:JsonReader>
                    <Fields>
                        <ext:RecordField Name="containerId" />
                        <ext:RecordField Name="noOfBags" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
            <SortInfo Field="containerId" Direction="ASC" />
            <Listeners>
                <LoadException Handler="Ext.Msg.alert('Containers - Load failed', e.message || e )" />
                <CommitFailed Handler="Ext.Msg.alert('Containers - Commit failed', 'Reason: ' + msg)" />
                <SaveException Handler="Ext.Msg.alert('Containers - Save failed', e.message || e)" />
                <CommitDone Handler="Ext.Msg.alert('Containers - Commit', 'The data was saved successfully');" />
            </Listeners>
        </ext:Store>
    I am not aware how to define ReaderIds. Can you provide some sample??
  4. #4

    RE: [CLOSED] Using Coolite Store without ASP.NET Data Sources

    Hi,

    ReaderID - Name of the property within a row object that contains a record identifier value.

    Please see the following code which shows how to set ReaderID

            <Reader ReaderID="containerId">
                <ext:JsonReader>
                    <Fields>
                        <ext:RecordField Name="containerId" />
                        <ext:RecordField Name="noOfBags" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
    Please note that ReaderID property can be absent in Fields (but you can add to Fields if need show this ID property in grid)

    Hope this help


  5. #5

    RE: [CLOSED] Using Coolite Store without ASP.NET Data Sources

    For one thing, ReaderID should have been specified on the JSon Reader.

    For another, although now I have everything working fine, just for a check up, please see if the Confirmation is intended to be provided in the following way, or am I doing something wrong:

            Protected Sub store1_BeforeRecordInserted(ByVal sender As Object, ByVal e As Coolite.Ext.Web.BeforeRecordInsertedEventArgs) Handles store1.BeforeRecordInserted
                Dim info As New LCInvoiceGoodConsignmentContainerInfo
                info.containerId = CStr(e.NewValues("containerId"))
                info.noOfBags = CInt(e.NewValues("noOfBags"))
                info.lcInvoiceGoodConsignment = New LCInvoiceGoodConsignmentInfo(Me.lcInvoiceGoodConsignmentId.Value)
    
                LCController.addLCInvoiceGoodConsignmentContainer(info, New Common.LogInfo(Me))
                Me.insertedValue = info.lcInvoiceGoodConsignmentContainerId.ToString
                e.Confirmation.Confirm = True
                e.Confirmation.ConfirmRecord(info.lcInvoiceGoodConsignmentContainerId)
            End Sub
    
            Private Sub Store1_AfterRecordInserted(ByVal sender As Object, ByVal e As AfterRecordInsertedEventArgs) Handles store1.AfterRecordInserted
                ''The deleted and updated records confirms automatic (depending AffectedRows field)
                ''But you can override this in AfterRecordUpdated and AfterRecordDeleted event
                ''For insert we should set new id for refresh on client
                ''If we don't set new id then old id will be used
                If (e.Confirmation.Confirm AndAlso Not String.IsNullOrEmpty(insertedValue)) Then
                    e.Confirmation.ConfirmRecord(insertedValue)
                    insertedValue = ""
                End If
            End Sub
    Here, the Id field is "lcInvoiceGoodConsignmentContainerId" (not container id). "lcInvoiceGoodConsignmentId" is the foreign key. Both fields are NOT visible in the Grid. The foreign key value is available in the code-behind as a private webform variable, that I have used above. The rest of the Code is self-explanatory.
  6. #6

    RE: [CLOSED] Using Coolite Store without ASP.NET Data Sources

    Hi,

    Sorry, it is my fault, ReaderID is property of JsonReader (other readers have ReaderID also) . Thank you for correction.

    Can you explain why you confirmed a record in Before and After handlers? You can confirm in only one handler.

  7. #7

    RE: [CLOSED] Using Coolite Store without ASP.NET Data Sources

    Also this example can be interested for you
    https://examples1.ext.net/#/GridPane.../Confirmation/

    (Only you can't test it online because database is read only now)


  8. #8

    RE: [CLOSED] Using Coolite Store without ASP.NET Data Sources

    Sorry for the late reply. Yes, only a single confirmation is required.
    And I cheked out the web-service example. Might use it at otehr place.

    Thanx. The issue is resolved.

Similar Threads

  1. Replies: 1
    Last Post: Dec 11, 2011, 6:45 AM
  2. Replies: 5
    Last Post: May 17, 2011, 9:10 AM
  3. Replies: 0
    Last Post: Jan 19, 2010, 10:24 AM
  4. [CLOSED] Data Store deriving invalid data variable name
    By SFritsche in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: May 15, 2009, 12:31 PM
  5. Replies: 10
    Last Post: Nov 20, 2008, 3:17 PM

Posting Permissions