Use Bind and BindString simultaneously

  1. #1

    Use Bind and BindString simultaneously

    On the following example, Text property has a fixed value (line 20) and FieldLabel property is bind to ViewModel (line 22).

    <script runat="server">
        public class MyModel
        {
            public static object Model = new
            {
                data = new
                {
                    title = "Raphael",
                    description = "Saldanha"
                }
            };
        }
    </script>
    <html>
    <head runat="server">
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager ScriptMode="Debug" runat="server" />
            <ext:TextField ViewModel="<%# MyModel.Model %>" Text="Fixed Text" AutoDataBind="true" runat="server">
                <Bind>
                    <ext:Parameter Name="fieldLabel" Value="{title}" />
                </Bind>
            </ext:TextField>
        </form>
    </body>
    </html>
    It's also possible to bind both Text and FieldLabel (lines 22 and 23)
    <script runat="server">
        public class MyModel
        {
            public static object Model = new
            {
                data = new
                {
                    title = "Raphael",
                    description = "Saldanha"
                }
            };
        }
    </script>
    <html>
    <head runat="server">
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager ScriptMode="Debug" runat="server" />
            <ext:TextField ViewModel="<%# MyModel.Model %>" AutoDataBind="true" runat="server">
                <Bind>
                    <ext:Parameter Name="fieldLabel" Value="{title}" />
                    <ext:Parameter Name="value" Value="{description}" />
                </Bind>
            </ext:TextField>
        </form>
    </body>
    </html>
    But when BindString is used simultaneously with Bind, only Text property (BindString) is bind correctly.
    <script runat="server">
        public class MyModel
        {
            public static object Model = new
            {
                data = new
                {
                    title = "Raphael",
                    description = "saldanha"
                }
            };
        }
    </script>
    <html>
    <head runat="server">
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager ScriptMode="Debug" runat="server" />
            <ext:TextField ViewModel="<%# MyModel.Model %>" BindString="{description}" AutoDataBind="true" runat="server">
                <Bind>
                    <ext:Parameter Name="fieldLabel" Value="{title}" />
                </Bind>
            </ext:TextField>
        </form>
    </body>
    </html>
    Is that the expected behaviour?

    Thanks in advance.
    Last edited by RaphaelSaldanha; Mar 24, 2016 at 6:15 PM.
  2. #2
    Hello Raphael!

    I am afraid this is the expected behavior.

    If you look at the generated code, you'll see that the bind: property overlaps with two definitions in different syntaxes (one object-oriented, other string oriented):

    This is the output of your third example:
    Ext.create("Ext.form.field.Text", {
        id: "ctl07",
        bind: {
            "fieldLabel": "{title}"
        },
        viewModel: {
            "data": {
                "title": "Raphael",
                "description": "saldanha"
            }
        },
        bind: "{description}",
        renderTo: "App.ctl07_Container",
        note: "ex3"
    });
    So, the used option is the one from BindString which gets output later.

    In other words, the <Bind> tag and BindString= properties are mutually exclusive.
    Last edited by fabricio.murta; Mar 28, 2016 at 8:29 PM. Reason: foo is bar as var is bar
    Fabrício Murta
    Developer & Support Expert
  3. #3
    I agree with you FabrÃ*cio.

    Thank you for your considerations.

Similar Threads

  1. Replies: 6
    Last Post: May 18, 2015, 7:58 PM
  2. Replies: 5
    Last Post: Sep 19, 2013, 11:36 AM
  3. Replies: 1
    Last Post: Sep 09, 2013, 7:04 AM
  4. Replies: 1
    Last Post: Nov 20, 2012, 9:27 AM
  5. Saving two or more grids simultaneously....
    By speedstepmem2 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jan 11, 2009, 11:07 AM

Posting Permissions