[CLOSED] DataBinding multiple controls to the same RecordField?

  1. #1

    [CLOSED] DataBinding multiple controls to the same RecordField?

    Hi,

    I realize no two controls on the page can share the same DataIndex property. But is there any viable alternative to that? For instance, I have a grid databound form that allows the user to edit details and another that creates a new set of details. Some fields on both should be pre-populated with the data from the same record fields. What's the best way to achieve that behavior other than manually set the values on the second form?

    Thanks,

    Vadym
    Last edited by Daniil; Jun 22, 2012 at 3:22 PM. Reason: [CLOSED]
  2. #2
    Hi,

    I think you can use the same DataIndex in the different FormPanels.

    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)
            {
                this.Store1.DataSource = new object[]
                {
                    new object[] { "some value" }  
                };
                this.Store1.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>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:Store ID="Store1" runat="server">
                <Reader>
                    <ext:ArrayReader>
                        <Fields>
                            <ext:RecordField Name="test" />
                        </Fields>
                    </ext:ArrayReader>
                </Reader>
            </ext:Store>
    
            <ext:FormPanel ID="FormPanel1" runat="server" Title="FormPanel1">
                <Items>
                    <ext:TextField runat="server" DataIndex="test" />
                </Items>
            </ext:FormPanel>
    
            <ext:FormPanel ID="FormPanel2" runat="server" Title="FormPanel2">
                <Items>
                    <ext:TextField runat="server" DataIndex="test" />
                </Items>
            </ext:FormPanel>
    
            <ext:Button runat="server" Text="Load">
                <Listeners>
                    <Click Handler="var record = Store1.getAt(0);
                                    FormPanel1.getForm().loadRecord(record);
                                    FormPanel2.getForm().loadRecord(record);" />
                </Listeners>
            </ext:Button>
        </form>
    </body>
    </html>
  3. #3
    Thanks, I'm now clear on how it works! You can mark this question as resolved.

    Vadym

Similar Threads

  1. [CLOSED] Eventmask - Targeting multiple controls
    By Pablo_Azevedo in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 13, 2012, 3:02 PM
  2. Replies: 7
    Last Post: Jun 28, 2011, 11:13 AM
  3. [CLOSED] Multiple User Controls problem
    By CMA in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: May 12, 2011, 12:38 PM
  4. Replies: 6
    Last Post: May 09, 2011, 9:24 PM
  5. Multiple ext controls in single anchor (or workaround)
    By dlouwers in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Dec 04, 2008, 12:53 PM

Tags for this Thread

Posting Permissions