[CLOSED] [#484] Change code to solved that the CheckboxGroupFor doesn't auto checked when the property type is array

  1. #1

    [CLOSED] [#484] Change code to solved that the CheckboxGroupFor doesn't auto checked when the property type is array

    Hi!
    I have a class which has a property LimitToSites, it type is List<Guid>, then i write some code in Cshtml like this

                                                Html.X().CheckboxGroupFor(p => p.SelectedSiteIds,
                                                    Model.AvailableSites.Select(p => new Checkbox.Config
                                                    {
                                                        BoxLabel = p.Name,
                                                        InputValue = p.Id.ToString()
                                                    })
                                                )
    I hope these checkboxes auto checked, but they wasn't. So, i read the file at Ext.Net.vs2013\Ext.Net\MVC\Extensions\WidgetExtens ions.cs, in row 425 i saw these code:

                List<string> values = new List<string>((model != null ? model.ToString().Split(',') : new string[0]));
    And, i change the code like this:

    
                List<string> values = new List<string>();
                if (model != null)
                {
                    if (model.GetType().IsArray)
                    {
                        foreach (var item in (model as Array))
                        {
                            values.Add(item.ToString());
                        }
                    }
                    else
                    {
                        values.AddRange((model != null ? model.ToString().Split(',') : new string[0]));
                    }
                }
    It's worked will! So, i hope the code will be add to the next version, thank you!
    Last edited by Daniil; May 08, 2014 at 7:59 AM. Reason: CLOSED]
  2. #2
    Hi @macroe,

    Please clarify is a duplicate?
    http://forums.ext.net/showthread.php?34201
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @macroe,

    Please clarify is a duplicate?
    http://forums.ext.net/showthread.php?34201
    Yes, it's duplicate.
  4. #4
    Removed.

    Thank you for the request, created an Issue:
    https://github.com/extnet/Ext.NET/issues/484

    Done in the revision #5830 (trunk).

Similar Threads

  1. Replies: 2
    Last Post: Dec 08, 2012, 7:41 PM
  2. Replies: 2
    Last Post: Jan 09, 2012, 7:18 AM
  3. Change input type based on data type
    By bjones in forum 1.x Help
    Replies: 5
    Last Post: Jan 06, 2012, 9:54 AM
  4. Replies: 2
    Last Post: Apr 28, 2011, 1:34 PM

Posting Permissions