)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Essential JS2

Syncfusion jQuery based widgets are no longer in active development. Switch to our pure JavaScript based next generation Essential JS 2 library.

Syncfusion Feedback

How to render PivotGrid using custom JSON data?

Platform: jQuery |
Control: ejPivotGrid |
Published Date: June 18, 2019 |
Last Revised Date: June 18, 2019 |
Product Version: 12.1.0.43

This KB illustrates that how to render PivotGrid using custom JSON data.

Solution:

The PivotGrid control normally gets rendered through the JSON data returned from WCF service after processing the report. You can also render the PivotGrid control by directly binding the custom JSON data structured in a format that is acceptable by PivotGrid.

WCF

public Dictionary<string, object> InitializeGrid(string action)
        {
            string[] index = { "0,0", "0,1", "0,2", "0,3", "0,4", "0,5", "1,0", "1,1", "1,2", "1,3", "1,4", "1,5"};
            string[] css = { "none", "rowheader", "rowheader", "rowheader", "rowheader", "summary", "colheader", "value", "value", "value", "value", "summary value" };
            string[] value = { "", "FY 2002", "FY 2003", "FY 2004", "FY 2005", "Total", "Internet Sales Amount", "$7,072,084.24", "$5,762,134.30", "$16,473,618.05", "$50,840.63", "$29,358,677.22" };
            string[] info = { "", "[Date].[Fiscal].[Fiscal Year].&[2002];[Date].[Fiscal].[Fiscal Year];FY 2002;[Date].[Fiscal].[All Periods];System.Linq.Enumerable+WhereSelectEnumerableIterator`2[<>f__AnonymousType2`2[Syncfusion.Olap.Data.Tuple,Syncfusion.Olap.Data.Member],System.String];1", "[Date].[Fiscal].[Fiscal Year].&[2003];[Date].[Fiscal].[Fiscal Year];FY 2003;[Date].[Fiscal].[All Periods];System.Linq.Enumerable+WhereSelectEnumerableIterator`2[<>f__AnonymousType2`2[Syncfusion.Olap.Data.Tuple,Syncfusion.Olap.Data.Member],System.String];1", "[Date].[Fiscal].[Fiscal Year].&[2004];[Date].[Fiscal].[Fiscal Year];FY 2004;[Date].[Fiscal].[All Periods];System.Linq.Enumerable+WhereSelectEnumerableIterator`2[<>f__AnonymousType2`2[Syncfusion.Olap.Data.Tuple,Syncfusion.Olap.Data.Member],System.String];1",
              "[Date].[Fiscal].[Fiscal Year].&[2005];[Date].[Fiscal].[Fiscal Year];FY 2005;[Date].[Fiscal].[All Periods];System.Linq.Enumerable+WhereSelectEnumerableIterator`2[<>f__AnonymousType2`2[Syncfusion.Olap.Data.Tuple,Syncfusion.Olap.Data.Member],System.String];1", "Date].[Fiscal].[All Periods];[Date].[Fiscal];All Periods;;System.Linq.Enumerable+WhereSelectEnumerableIterator`2[<>f__AnonymousType2`2[Syncfusion.Olap.Data.Tuple,Syncfusion.Olap.Data.Member],System.String];1", "[Measures].[Internet Sales Amount];[Measures].[MeasuresLevel];Internet Sales Amount;;System.Linq.Enumerable+WhereSelectEnumerableIterator`2[<>f__AnonymousType2`2[Syncfusion.Olap.Data.Tuple,Syncfusion.Olap.Data.Member],System.String];1", "", "", "", "", ""};
            ExpandableState[] state = { ExpandableState.None, ExpandableState.None, ExpandableState.None, ExpandableState.None, ExpandableState.None, ExpandableState.None, ExpandableState.None, ExpandableState.None, ExpandableState.None, ExpandableState.None, ExpandableState.None,ExpandableState.None };
            int[] rowspan = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
            int[] colspan = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, };
            string[] span = { "None", "None", "None", "None", "None", "None", "None", "None", "None", "None", "None", "None" };
            List<object> pivotEngineRecords = new List<object>();
            for (int i = 0; i < index.Length; i++)
            {
                pivotEngineRecords.Add(new { Index= index[i], CSS= css[i], Value= value[i], Info= info[i], State= state[i], RowSpan= rowspan[i], ColSpan= colspan[i], Span= span[i] });
            }
            string jsonData = serializer.Serialize(pivotEngineRecords);
            Dictionary<string, object> dic = new Dictionary<string, object>();
            dic.Add("jsonData", jsonData);
            dic.Add("report", "");
            return (dic);
        }

 

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon