PDA

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



macroe
May 07, 2014, 2:00 PM
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!

Daniil
May 07, 2014, 3:02 PM
Hi @macroe,

Please clarify is a duplicate?
http://forums.ext.net/showthread.php?34201

macroe
May 08, 2014, 6:16 AM
Hi @macroe,

Please clarify is a duplicate?
http://forums.ext.net/showthread.php?34201

Yes, it's duplicate.

Daniil
May 08, 2014, 7:58 AM
Removed.

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

Done in the revision #5830 (trunk).