Grid value accessing from server side

  1. #1

    Grid value accessing from server side

    I have used followed way to get values from client to server side it works fine. But is their any other way that i can directly access values of grid from server side without passing from client side ie by clicking save button

     <ext:Button ID="btnsave" Icon="Accept" CausesValidation="true" FormBind="true" Text="save"
                        Height="13" runat="server" >                 
                        <DirectEvents>
                            <Click OnEvent="btnsave_Click">
                                <ExtraParams>
                                    <ext:Parameter Name="Values" Value="Ext.encode(#{GridInvoiceDetails}.getRowsValues({selectedOnly : false}))"
                                        Mode="Raw" />
                                </ExtraParams>
                                <EventMask ShowMask="true" Msg="Please wait..." />
                            </Click>
                        </DirectEvents>
                    </ext:Button>
  2. #2
    Hello!

    Grid stores all values in store which store doesn't send own values by default. You have to send data manually.
  3. #3
    Could you give me small example to send manually grid data
  4. #4
    Try this one:

    <%@ 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)
            {
                this.Store1.DataSource = this.Data;
                this.Store1.DataBind();
            }
        }
    
        private object[] Data
        {
            get
            {
                return new object[]
                {
                    new object[] { "3m Co", 71.72, 0.02, 0.03, "9/1 12:00am" },
                    new object[] { "Alcoa Inc", 29.01, 0.42, 1.47, "9/1 12:00am" },
                    new object[] { "Altria Group Inc", 83.81, 0.28, 0.34, "9/1 12:00am" },
                    new object[] { "American Express Company", 52.55, 0.01, 0.02, "9/1 12:00am" },
                    new object[] { "American International Group, Inc.", 64.13, 0.31, 0.49, "9/1 12:00am" },
                    new object[] { "AT&T Inc.", 31.61, -0.48, -1.54, "9/1 12:00am" }
                };
            }
        }
        
        protected void Button1_Click(object sender, DirectEventArgs e)
        {
            var s = e.ExtraParams["storeValues"];
        }
    </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 Examples</title>
    </head>
    <body>
        <ext:ResourceManager runat="server" />
        
        <ext:GridPanel 
            ID="GridPanel1"
            runat="server" 
            StripeRows="true"
            Title="Array Grid" 
            TrackMouseOver="true"
            Width="600" 
            Height="350"
            AutoExpandColumn="company">
            <Buttons>
                <ext:Button runat="server" ID="Button1" Text="Send Store Data to the Server">
                    <DirectEvents>
                        <Click OnEvent="Button1_Click">
                            <ExtraParams>
                                <ext:Parameter Name="storeValues" Value="GridPanel1.getStore().getRecordsValues()" Mode="Raw"  Encode="True" />
                            </ExtraParams>
                        </Click>
                    </DirectEvents>
                </ext:Button>
            </Buttons>
            <Store>
                <ext:Store ID="Store1" runat="server">
                    <Reader>
                        <ext:ArrayReader>
                            <Fields>
                                <ext:RecordField Name="company" />
                                <ext:RecordField Name="price" Type="Float" />
                                <ext:RecordField Name="change" Type="Float" />
                                <ext:RecordField Name="pctChange" Type="Float" />
                                <ext:RecordField Name="lastChange" Type="Date" DateFormat="M/d hh:mmtt" />
                            </Fields>
                        </ext:ArrayReader>
                    </Reader>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:Column ColumnID="Company" Header="Company" DataIndex="company" />
                    <ext:Column Header="Price" DataIndex="price">                  
                    </ext:Column>
                    <ext:Column ColumnID="Change" Header="Change" DataIndex="change">
                    </ext:Column>
                    <ext:Column Header="Change" DataIndex="pctChange">
                    </ext:Column>
                    <ext:DateColumn Header="Last Updated" DataIndex="lastChange" />
                </Columns>
            </ColumnModel>
            <SelectionModel>
                <ext:RowSelectionModel runat="server" SingleSelect="true" />
            </SelectionModel>
        </ext:GridPanel>
    </body>
    </html>
  5. #5
    Sorry to say but as i already told you it works fine.
    I want to ask you that is their any other way from i can directly access grid elments or rows values without passing through Direct Parameter or i should send it from jquery or javascript that DirectEvent object for server side method.
  6. #6
    If you want to use DirectEvent using ExtraParams is the best option. However, you can try to use hidden field and set its value using DirectEvent's Before property
  7. #7
    Hey I got the way.
    I used by followed way n it works fine
    Client Side Example 1 by using jquery
    $(document).ready(function () {
     $("#btnServerCall").click(function () {
                    
                    Ext.net.DirectMethods.SaveIn(Ext.encode(GridInvoiceDetails.getRowsValues({ selectedOnly: false })));
                   
                    return false;
                });});
    <button id="btnServerCall"  > Server Call</button>
    
    
    Client Side Example 2 by on click
     <button id="btnServerCall" class="button" onclick="Ext.net.DirectMethods.SaveIn(Ext.encode(GridInvoiceDetails.getRowsValues({ selectedOnly: false })));" >
                                                                Server Call</button>
    
    Server Side for both same
    [DirectMethod]
        public void SaveIn(sting GridElements)
        {
      XmlNode xml1 = JSON.DeserializeXmlNode("{records:{record:" + GridElements+ "}}");
             foreach (XmlNode row in xml1.SelectNodes("records/record"))
            {
                           int ID = Convert.ToInt32(row.SelectSingleNode("ID ").InnerXml);
    
    }
        }
    now you can close this thread. :)
    Last edited by Roshan; Mar 01, 2013 at 10:08 AM.

Similar Threads

  1. [CLOSED] Server side row click of grid panel row
    By otouri in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Dec 17, 2012, 4:00 PM
  2. get selected row in grid and pass to server side
    By Aleksa007 in forum 1.x Help
    Replies: 0
    Last Post: Mar 07, 2011, 11:58 PM
  3. Clear Grid data server side
    By bsnezw in forum 1.x Help
    Replies: 2
    Last Post: Oct 26, 2009, 11:48 AM
  4. Update grid from Server Side
    By Maia in forum 1.x Help
    Replies: 3
    Last Post: Jun 03, 2009, 2:21 PM
  5. Replies: 3
    Last Post: Oct 24, 2008, 2:05 PM

Posting Permissions