XForm Statistics - Polls - EPiServer 7 MVC

Vote:
 

Has anyone been able to get XForm Statistics - Polls to work in EPiServer 7 using MVC ? If so please can you guide me in the right direction

Thanks

Minesh

#74990
Sep 13, 2013 11:39
Vote:
 

Hi, 

did you maybe found the solution for this ?

I am trying to do custom rendering in MVC. I can get statistics via GetPostedDataStatistics(....) but I dont know how to get the select options. I can get them if somebody already voted by GetPostedData() for every voted select option but I don't think that this is the way. Should I parse Form.Document xml to get all available options?

Thanks, 

Simona

#113692
Nov 26, 2014 15:59
Vote:
 

I have succeded on this way:

var htmlFragments = form.CreateHtmlFragments();
                        var choices = new List<PollAnswerViewModel>();
                        foreach (var item in htmlFragments)
                        {
                            if (item is EPiServer.XForms.Parsing.Select1AsRadiobuttonFragment)
                            {
                                var fragment = item as EPiServer.XForms.Parsing.Select1AsRadiobuttonFragment;
                                var options = fragment.Options;
                                foreach (var select in options)
                                {
                                    var pollAnswerItem = new PollAnswerViewModel
                                    {
                                        Answer = @select.Text,
                                        Value = @select.Value
                                    };
                                    choices.Add(pollAnswerItem);
                                }
                                viewModel.PollAnswers = choices;
                                break;
                            }
                        }



If somebody maybe has the better way, please say it :)

Thanks

#113777
Nov 27, 2014 15:40
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.