[CLOSED] [#166] Generate Radio Group Dynamically with the help of Model.

  1. #1

    [CLOSED] [#166] Generate Radio Group Dynamically with the help of Model.

    I have PaymentPeriodList in my Model. I am trying to create Radio Group but its giving me the attached error.
    Click image for larger version. 

Name:	error.jpg 
Views:	59 
Size:	100.7 KB 
ID:	5780

     Html.X().Container()
                                                            .Border(false)
                                                            .Layout(LayoutType.HBox)
                                                            .LayoutConfig(new HBoxLayoutConfig { Align = HBoxAlign.Top })
                                                            .Items(
                                                                                        Html.X().RadioGroup().GroupName("PaymentPeriod")
                                                                                        .Items(
                                                                                           from rd in Model.PaymentPeriodList
                                                                                           select new Ext.Net.Radio { ID = rd.Desc,BoxLabel=rd.Desc,Checked=false,Name="paymentper" }
                                                                                        )
    
                                                                                        .FieldLabel("Payment Period")
                                                                  )
    Last edited by Daniil; Apr 02, 2013 at 12:28 PM. Reason: [CLOSED]
  2. #2
    Hi @alscg,

    Thank you for the report. Here is a test case. We are investigating.

    Example View
    @model Work2MVC.Models.TestModel
    
    <!DOCTYPE html>
    
    <html>
    <head>
        <title>Ext.Net.MVC v2 Example</title>    
    </head>
    <body>
        @Html.X().ResourceManager()
    
        @(Html.X().RadioGroup()
            .Items(
                from radio in Model.Radios
                select new Ext.Net.Radio
                {
                    ID = radio.ID,
                    BoxLabel = radio.ID
                }
            )
        )
    </body>
    </html>
    Example Model
    public class MyRadio
    {
        public string ID{ get; set; }
    }
    
    public class TestModel
    {
        public MyRadio[] Radios 
        {
            get
            {
                return new MyRadio[]
                {
                    new MyRadio()
                    {
                        ID = "Radio1"   
                    },
                    new MyRadio()
                    {
                        ID = "Radio2"
                    }
                };
            }
        }
    }
    Example Action
    public ActionResult Index()
    {
        return View(new TestModel());
    }
  3. #3
    It needs to call the ToList method.
    @(Html.X().RadioGroup()
        .Items(
            (from radio in Model.Radios
            select new Ext.Net.Radio
            {
                ID = radio.ID,
                BoxLabel = radio.ID
            }).ToList<Radio>()
        )
    )
  4. #4
    Thanks Daniil.It works for me.

    Radio Button is getting generated using Model but I am not getting any option to get the Checked radio button value as we get the value of
    TextboxFor and ComboBoxFor Controls.

    The value of Textbox and Combobox gets populated into the Model Property.But how to do the same thing for Radio Group Selection?
  5. #5
    For now you can populate the Checked property from a Model manually.

    But we will consider a possibility to implement RadioGroupFor and CheckboxGroupFor.
  6. #6
    Quote Originally Posted by Daniil View Post
    But we will consider a possibility to implement RadioGroupFor and CheckboxGroupFor.
    We created an Issue.
    https://github.com/extnet/Ext.NET/issues/166
  7. #7
    We are investigating this issue today and hopefully will be able to post updated functionality to SVN very soon.
    Geoffrey McGill
    Founder
  8. #8
    We are continuing to implement the RadioGroupFor and CheckboxGroupFor Model helpers.

    We have also decided to implement CheckboxGroupForEnum and RadioGroupForEnum Model helpers.

    Examples for all these new Model helpers will be added to the MVC Examples Explorer.

    Everything should be complete within the next few days.
    Geoffrey McGill
    Founder
  9. #9
    It has been committed to SVN. The example is here:
    Ext.Net.Examples.MVC\Areas\Form_Groups\Views\GroupFor\Index.cshtml
    Thank you for the feature request. The new functionality should be useful.
  10. #10

    Radiogroup dynamic with loop

    Hello,

    I have a similar problem. I'm not sure if I'm asking for a functionality which is very obvious, but I was not able to get this functionality up and running. I opened a new thread for my problem here.
    http://forums.ext.net/showthread.php...sing-loop(MVC)

    could you please let me know the error in the code.

    Thanks,

Similar Threads

  1. MVC Razor – Dynamically generate view
    By Ishrath in forum 2.x Help
    Replies: 0
    Last Post: Oct 11, 2012, 3:54 AM
  2. Retrieve checked radio from Radio Group
    By ttharaka2002 in forum 1.x Help
    Replies: 0
    Last Post: Mar 25, 2010, 2:15 AM
  3. radio group setvalue
    By [WP]joju in forum 1.x Help
    Replies: 1
    Last Post: Jan 11, 2010, 4:35 AM
  4. [CLOSED] Dynamic Creation of Radio Buttons within Radio Group
    By Steve in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Mar 04, 2009, 1:13 PM
  5. Radio Group
    By amitpareek in forum 1.x Legacy Premium Help
    Replies: 0
    Last Post: Dec 04, 2008, 5:06 PM

Posting Permissions