[CLOSED] How to step through data in a data store

  1. #1

    [CLOSED] How to step through data in a data store

    I'm creating a store in markup and binding data in code behind. What is the easiest way to step through this data row by row in code behind or can it only be done in javascript? Here is my sample code:

            <ext:Store ID="StoreIssuesPrint" runat="server">
                <Reader>
                    <ext:ArrayReader>
                        <Fields>
                            <ext:RecordField Name="id" />
                            <ext:RecordField Name="issuename" />
                            <ext:RecordField Name="issueyear"  />
                            <ext:RecordField Name="issueset"  />
                            <ext:RecordField Name="issuedate" Type="Date" />
                        </Fields>
                    </ext:ArrayReader>
                </Reader>
            </ext:Store>
    
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
                StoreIssuesPrint.DataSource = New Object() {New Object() {1, "Jan", 2010, 1, "1/1/2010"}, _
                                                          New Object() {2, "Feb", 2010, 1, "2/1/2010"}, _
                                                          New Object() {3, "Mar", 2010, 1, "3/1/2010"}, _
                                                          New Object() {4, "Apr", 2010, 1, "4/1/2010"}, _
                                                          New Object() {5, "May", 2010, 1, "5/1/2010"}, _
                                                          New Object() {6, "Jun", 2010, 1, "6/1/2010"}, _
                                                          New Object() {7, "Jul", 2010, 1, "7/1/2010"}, _
                                                          New Object() {8, "Aug", 2010, 1, "8/1/2010"}, _
                                                          New Object() {9, "Sep", 2010, 1, "9/1/2010"}, _
                                                          New Object() {10, "Oct", 2010, 1, "10/1/2010"}, _
                                                          New Object() {11, "Nov", 2010, 1, "11/1/2010"}, _
                                                          New Object() {12, "Dec", 2010, 1, "12/1/2010"}, _
                                                          New Object() {13, "Q1", 2010, 3, "1/1/2010"}, _
                                                          New Object() {14, "Q2", 2010, 3, "4/1/2010"}, _
                                                          New Object() {15, "Q3", 2010, 3, "7/1/2010"}, _
                                                          New Object() {16, "Q4", 2010, 3, "10/1/2010"}, _
                                                          New Object() {17, "Annual", 2010, 5, "1/1/2010"}}
                StoreIssuesPrint.DataBind()
                SetupPrintAdIssues()
        End Sub
    
        Public Sub SetupPrintAdsIssues()
            'Step through StoreIssuesPrint
            For Each row in StoreIssuesPrint ????
        ?????How do I access each row and column of data
            Next
         End Sub
    Thank you for any pointers you can provide.
    Last edited by Daniil; Oct 29, 2010 at 3:05 PM. Reason: [CLOSED]
  2. #2
    Hi,

    You could organize a DataSource by a way to go trough it easily, then .DataBind().

    If you need to have an access to values from client side please submit Store's values and deserialize it on server side.

    Please investigate this example.
    https://examples1.ext.net/#/GridPane...mit_Two_Grids/

    To update a Store's record from server side please use the Store's UpdateRecordField() method.
  3. #3
    Thank you for the suggestions, but I'm wondering if Coolite provides an interface to access store data like EXT.js. In the following Javascript example, the store data can be accessed using an item index; does Coolite have access to this same info in VB.NET?

     
                        for (var i = 0; i < store_AdInfo.data.items.length; i++) {
                            id = store_AdInfo.data.items[i].data.ID;
                            startdate = store_AdInfo.data.items[i].data.StartDate;
                            enddate = store_AdInfo.data.items[i].data.EndDate;
                            position = store_AdInfo.data.items[i].data.Position;
                            amount = store_AdInfo.data.items[i].data.Amount;
                            impressions = store_AdInfo.data.items[i].data.Impressions;
       
                           //Save the data in another place.
                           Coolite.AjaxMethods.SaveBanner(id, startdate, enddate, position, amount, impressions);
                           }
  4. #4
    Hi iansriley,

    store.data.items
    This object is placed on client side only. Often it's a huge object. So, It would be a very expensive operation to pass this object to a server each time. In addition it would be very complicated to realize a good mechanism of synchronization data.items between a client and a server. Therefore there is no collection like data.items on server side.

    Please look at the technique how you can go through Store's records on server side.

    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)
            {
                Store store = this.GridPanel1.GetStore();
                store.DataSource = new object[] { 
                                             new object[] {"test11", "test12", "test13"},
                                             new object[] {"test21", "test22", "test23"},
                                             new object[] {"test31", "test32", "test33"}
                                    };
                store.DataBind();
            }
        }
    
        protected void ReadRecords(object sender, DirectEventArgs e)
        {
            string jsonValues = e.ExtraParams["values"];
            List<Dictionary<string, string>> records = JSON.Deserialize<List<Dictionary<string, string>>>(jsonValues);
            string result = "";
            foreach (var record in records)
            {
                result += record["id"] + " ";
                result += record["test1"] + " ";
                result += record["test2"] + " ";
                result += record["test3"] + "<br />";
            }
            X.Msg.Alert("Server", result).Show();
        }
    </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 Example</title>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true">
            <Store>
                <ext:Store runat="server">
                    <Reader>
                        <ext:ArrayReader>
                            <Fields>
                                <ext:RecordField Name="test1" />
                                <ext:RecordField Name="test2" />
                                <ext:RecordField Name="test3" />
                            </Fields>
                        </ext:ArrayReader>
                    </Reader>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:Column Header="Test1" DataIndex="test1" />
                    <ext:Column Header="Test2" DataIndex="test2" />
                    <ext:Column Header="Test3" DataIndex="test3" />
                </Columns>
            </ColumnModel>
        </ext:GridPanel>
        <ext:Button runat="server" Text="Read Store's records on server side">
            <DirectEvents>
                <Click OnEvent="ReadRecords">
                    <ExtraParams>
                        <ext:Parameter 
                            Name="values" 
                            Value="GridPanel1.getRowsValues()" 
                            Mode="Raw" 
                            Encode="true" />
                    </ExtraParams>
                </Click>
            </DirectEvents>
        </ext:Button>
        </form>
    </body>
    </html>
  5. #5
    That makes sense; thank you for the insight and the example...very helpful.
  6. #6
    Hi Daniil, is this information still valid, or are there new ways to access store/records in ext.net 2.x ?
  7. #7
    Well, it is still valid, by I am not 100% sure what exactly you mean by:

    Quote Originally Posted by blueworld View Post
    to access store/records in ext.net 2.x ?
  8. #8
    Quote Originally Posted by Daniil View Post
    Well, it is still valid, by I am not 100% sure what exactly you mean by:
    Well, for example, do you still need to submit row-values in order to loop through a grid in codebehind?
  9. #9
    Yes, there was no change regarding that.

Similar Threads

  1. Replies: 0
    Last Post: Apr 22, 2012, 9:39 AM
  2. Replies: 1
    Last Post: Mar 08, 2012, 2:52 PM
  3. Replies: 1
    Last Post: Dec 11, 2011, 6:45 AM
  4. Replies: 5
    Last Post: May 17, 2011, 9:10 AM
  5. [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

Tags for this Thread

Posting Permissions