How to pass objects in DirectEvents Methods

  1. #1

    How to pass objects in DirectEvents Methods

    Hello,

    I would like to know if there's a way to pass objects like Store in directevent method ?

    Thank you
  2. #2
    Hi,

    No, a Store can not be serialized on client. Please pass only required things from a Store.
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi,

    No, a Store can not be serialized on client. Please pass only required things from a Store.
    Ok, Thank you for the answer.

    So i'll explain my issue, and may be you will have a good solution :

    I have a server side method that conatins a store databind. What i need to do is that any store would be databinded with Click Event.

     public void Method_AddIssue(Ext.Net.Store MyStore, string ProjectId)
            {
                try
                {
    
                    SqlCommand selectCMD = new SqlCommand("select * from Issues where id=" + TF_Add_Issue_M1.Text, Conn);
                    SqlDataAdapter issueDA = new SqlDataAdapter();
                    issueDA.SelectCommand = selectCMD;
                    Conn.Open();
                    DataSet issueDS = new DataSet();
                    issueDA.Fill(issueDS);
                    int nbIssues = issueDS.Tables[0].Rows.Count;
                    Conn.Close();
    
                    if (nbIssues == 1)
                    {
                        string sAddSID;
                        sAddSID = "update issues set projectId=" + IssuesBuildId.Text + ", "
                            + " State = " + Convert.ToInt16(ConfigurationSettings.AppSettings["Scheduled"].ToString())
                            + " where id='" + TF_Add_Issue_M1.Text + "'";
    
                        SqlCommand sidSelector = new SqlCommand(sAddSID, Conn);
                        Conn.Open();
                        sidSelector.ExecuteNonQuery();
                       BindDataWithSorting(MyStore as Ext.Net.Store, "select * from issues where projectId=" + ProjectId);
                    }
                    else
                    {
                    }
                }
                catch (Exception exc)
                {
    
                }
    
            }
    Then in Client Side i have this :

    <ext:Button ID="Button_Add_Issue_M1" runat="server" Icon="ApplicationOsxAdd" Text="Add Issue" ToolTip="Click to Add a New Build to this Version" ToolTipType="Qtip"> 
                <Listeners>
                <Click Handler="XReleases.direct.Method_AddIssue(#{Store_M1_Issues},#{IssuesBuildId}.value);" />
                </Listeners>
                
             </ext:Button>
    Unfortunately this doesn't work.
    Do you have any idea about that?

    Thank you
  4. #4
    I suggest to send a Store ID and find a Store instance using the FindControl method.

    Example
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        [DirectMethod]
        public void Load(string storeServerID)
        {
            Store store = Ext.Net.Utilities.ControlUtils.FindControl<Store>(this.Page, storeServerID);
    
            store.DataSource = new object[] 
                { 
                    new object[] { "test1" },
                    new object[] { "test2" },
                    new object[] { "test3" },
                };
            store.DataBind();
        }
    </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>
        <ext:ResourceManager runat="server" />
        <ext:GridPanel runat="server" AutoHeight="true">
            <Store>
                <ext:Store ID="Store1" runat="server">
                    <Reader>
                        <ext:ArrayReader>
                            <Fields>
                                <ext:RecordField Name="test" />
                            </Fields>
                        </ext:ArrayReader>
                    </Reader>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:Column Header="Test" DataIndex="test" />
                </Columns>
            </ColumnModel>
        </ext:GridPanel>
        <ext:GridPanel runat="server" AutoHeight="true">
            <Store>
                <ext:Store ID="Store2" runat="server">
                    <Reader>
                        <ext:ArrayReader>
                            <Fields>
                                <ext:RecordField Name="test" />
                            </Fields>
                        </ext:ArrayReader>
                    </Reader>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:Column Header="Test" DataIndex="test" />
                </Columns>
            </ColumnModel>
        </ext:GridPanel>
        <ext:Button runat="server" Text="Load a data to the Store1">
            <Listeners>
                <Click Handler="Ext.net.DirectMethods.Load('Store1');" />
            </Listeners>
        </ext:Button>
        <ext:Button runat="server" Text="Load a data to the Store2">
            <Listeners>
                <Click Handler="Ext.net.DirectMethods.Load('Store2');" />
            </Listeners>
        </ext:Button>
    </body>
    </html>

Similar Threads

  1. RadioGroup with embeded objects
    By JsonTerre in forum 1.x Help
    Replies: 2
    Last Post: Sep 09, 2011, 2:21 AM
  2. aligning form objects
    By craig2005 in forum 1.x Help
    Replies: 2
    Last Post: Jan 06, 2011, 3:25 AM
  3. [CLOSED] how to pass combobox values through direct methods
    By dev in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Sep 08, 2010, 3:54 AM
  4. Show objects hidden
    By flaviodamaia in forum 1.x Help
    Replies: 2
    Last Post: Jul 28, 2009, 2:02 PM
  5. Grid methods
    By frytas in forum 1.x Help
    Replies: 0
    Last Post: Oct 28, 2008, 6:12 AM

Posting Permissions