[CLOSED] Mvc CustomAttributeBinding

  1. #1

    [CLOSED] Mvc CustomAttributeBinding

    Hi all,

    i need if is possible a sample of CustomAttributeBinding syntax with Razor view.

    Thanks.

    Best regards
    Last edited by Daniil; Dec 09, 2013 at 11:59 AM. Reason: [CLOSED]
  2. #2
    Can you provide more details about what is CustomAttributeBinding?
    Where we can read about it?

    Thanks
    Vladimir Shcheglov
    Sr. Developer
  3. #3
    Hi Vladimir,

    i tried to convert a piece of webform view to razor view.

      <ext:TreePanel
                              ID="TreePanel1"
                              runat="server"
                              Width="350"
                              Height="450"
                              AutoScroll="true">
                              <Store>
                                <ext:TreeStore ID="TreeStore1" runat="server" DataSourceID="MnuXmlDataSource">
                                  <DataBindings>
                                    <ext:NodeBinding DataMember="Funzioni" Text="Funzioni" ExpandedField="Expanded">
                                    </ext:NodeBinding>
                                    <ext:NodeBinding DataMember="Procedura" TextField="Text">
                                    </ext:NodeBinding>
                                    <ext:NodeBinding DataMember="Raggruppamento" TextField="Text" NodeIDField="NodeID">
                                      <CustomAttributeBindings>
                                        <ext:CustomAttributeBinding AttributeField="Security" />
                                      </CustomAttributeBindings>
                                    </ext:NodeBinding>
                                    <ext:NodeBinding DataMember="Funzione" TextField="Text" ExpandedField="Expanded" NodeIDField="NodeID">
                                      <CustomAttributeBindings>
                                        <ext:CustomAttributeBinding AttributeField="Security" />
                                      </CustomAttributeBindings>
                                    </ext:NodeBinding>
                                    <ext:NodeBinding DataMember="Gestione" TextField="Text" ExpandedField="Expanded" NodeIDField="NodeID" LeafField="IsLeaf" HrefField="Href" IconField="Icon">
                                      <CustomAttributeBindings>
                                        <ext:CustomAttributeBinding AttributeField="Security" />
                                        <ext:CustomAttributeBinding AttributeField="CodiceProcedura" />
                                      </CustomAttributeBindings>
                                    </ext:NodeBinding>
                                  </DataBindings>
                                </ext:TreeStore>
                              </Store>
    My razor view code is

    Html.X().TreePanel().ID("TreePanel1").Width(350).Height(450).AutoScroll(true)
              .Store(
            
                Html.X().ExtendedTreeStore().ID("TreeStore1").DataSourceID("MnuXmlDataSource")
                .DataBindings(
                
                new Ext.Net.NodeBinding {DataMember="Funzioni",Text="Funzioni",ExpandedField ="Expanded" },
                new Ext.Net.NodeBinding {DataMember="Procedura",TextField="Text" },
                  new Ext.Net.NodeBinding {DataMember="Raggruppamento",TextField="Text",NodeIDField="NodeID"}
                  .CustomAttributeBindings.Add(
                      new Ext.Net.CustomAttributeBinding { AttributeField="Security" })
                      
                    ));
    I get two errors

    1) on .Databindings :Error 1 The best overloaded method match for 'Ext.Net.TreeStoreBase.Builder<Ext.Net.TreeStore,E xt.Net.TreeStore.Builder>.DataBindings(params Ext.Net.NodeBinding[])' has some invalid arguments

    2) on .CustomAttributeBindings.Add : Error 2 Argument 3: cannot convert from 'void' to 'Ext.Net.NodeBinding'

    I tried also with this code:

    Html.X().TreePanel().ID("TreePanel1").Width(350).Height(450).AutoScroll(true)
              .Store(
            
                Html.X().ExtendedTreeStore().ID("TreeStore1").DataSourceID("MnuXmlDataSource")
                .DataBindings(
                
                new Ext.Net.NodeBinding {DataMember="Funzioni",Text="Funzioni",ExpandedField ="Expanded" },
                new Ext.Net.NodeBinding {DataMember="Procedura",TextField="Text" },
                  new Ext.Net.NodeBinding {DataMember="Raggruppamento",TextField="Text",NodeIDField="NodeID"}
                  .CustomAttributeBindings.Add(
                      new Ext.Net.CustomAttributeBinding { AttributeField="Security" })
                      
                    ));
    and i get only one error: Error 1 Non-invocable member 'Ext.Net.NodeBinding.CustomAttributeBindings' cannot be used like a method.

    Surely my syntax is wrong.
    Can you help me?

    Thanks
  4. #4
    Hello!

    It should look like this:
    @(Html.X().TreePanel().ID("TreePanel1").Width(350).Height(450).AutoScroll(true)
        .Store(
             Html.X().TreeStore()
                .ID("TreeStore1")
                .DataSourceID("MnuXmlDataSource")
                .DataBindings(db =>
                {
                    db.Add(new Ext.Net.NodeBinding {DataMember = "Funzioni", Text = "Funzioni", ExpandedField = "Expanded"});
                })
        )
    )
    Also, I don't quite understand what is ExtendedTreeStore?
  5. #5
    Hi Baidaly!

    Thanks for your answer.
    Sorry, "ExtendedTreeStore" is a write error during the transcription of the code.

    But my problem about "CustomAttributeBindings" remained.
    I am not able to add a "CustomAttributeBindings" to a NodeBinding in razor view.

    Any suggestion?

    Thanks!
  6. #6
    Regarding @Baidaly's sample:
    db.Add(new Ext.Net.NodeBinding
    {
        DataMember = "Funzioni",
        Text = "Funzioni",
        ExpandedField = "Expanded",
        CustomAttributeBindings =
        {
            new CustomAttributeBinding() { ... },
            new CustomAttributeBinding() { ... }
        }
    });
  7. #7
    Hi Daniil,

    your sample work fine!

    Many thanks, you can close the thread.

Posting Permissions