0

I have one table which stored questions as column names and answers as column values and want to display those data in PivotGrid2. For that, I have created the below model which stores the collection of values. Want to display that in pivotgrod2. I Can see data in PivotGrid2 but not in the proper format as a below-attached link.

Model - 
    public class WorkFlowReportDataModel
            {
                public string AllQuestions { get; set; }
                public string AllResponses { get; set; }
            }
Controller -
{
            var workFlowReportData = _workflowServices.GetWorkflowReportData(WorkFlowKey);

            var workFlowReportDataModelList = new List<WorkFlowReportDataModel>();
            foreach (DataRow dr in workFlowReportData.Rows)
            {
                
                foreach (DataColumn dc in workFlowReportData.Columns)
                {
                    var workFlowReportDataModel = new WorkFlowReportDataModel();
                    workFlowReportDataModel.AllQuestions = dc.ColumnName.ToString();
                    workFlowReportDataModel.AllResponses = dr[dc].ToString();
                    workFlowReportDataModelList.Add(workFlowReportDataModel);
                }
            }
    
View - 
    
        @(Html.Kendo().PivotContainer()
                                    .Name("container")
                                    .ConfiguratorPosition("left")
                                    .Content(@<text>
                                        @(Html.Kendo().PivotConfiguratorV2()
                                            .Name("configurator")
                                            .Sortable(true)
                                            .Filterable(true))
                                                        @(Html.Kendo().PivotGridV2<InvestrackV2.Controllers.WorkFlowController.WorkFlowReportDataModel>()
                                            .Name("pivot grid")
                                            .HtmlAttributes(new { @class = "hidden-on-narrow" })
                                            .Configurator("#configurator")
                                            .ColumnWidth(120)
                                            .Height(570)
                                            .BindTo(Model)
                                            .DataSource(dataSource => dataSource
                                                .Custom()
                                                .Schema(schema => schema
                                                    .Model(m => m.Field("AllQuestions", typeof(string)).From("AllQuestions"))
                                                    .Cube(cube => cube
                                                        .Dimensions(dimensions =>
                                                        {
                                                            dimensions.Add(model => model.AllQuestions).Caption("AllQuestions");
                                                            dimensions.Add(model => model.AllResponses).Caption("AllResponses");
                                                        })
                                                    //.Measures(measures =>
                                                    //{
                                                    //    measures.Add("Sum").Format("{0:c}").Field(model => model.SECTISUBSRange).AggregateName("sum");
                                                    //})
                                                    ))
                                                .Columns(columns =>
                                                {
                                                    columns.Add("AllQuestions").Expand(true);
                                                    columns.Add("AllResponses").Expand(true);
                                                })
                                                .Rows(rows => rows.Add("AllResponses").Expand(true))
                                            //.Measures(measures => measures.Values("Sum"))
                                            //.Events(e => e.Error("onError"))
                                            )
                                        )
                                        @(Html.Kendo().PivotConfiguratorButton()
                            .Name("Button")
                            .Configurator("configurator")
                                        )
                                    </text>))
    
    Output- Want to display All questions(COlumn names)Fields section so I can select the question name and see the answers for it. as below.
    
    
      [1]: https://i.stack.imgur.com/XucBI.png

0 Answers0