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. Image for the cookie policy date

DataTable binding

Hello,

How to bind a System.Data.DataTable object (or DataView object) with a PivotGrid control?

Thanks!

10 Replies

AD Alagarsamy D Syncfusion Team January 18, 2016 08:43 AM UTC

Hi Jorge,

Thank you for using Syncfusion products.

We have created a simple sample based on your requirement. Please find the sample in the below link.

Sample Link:
http://www.syncfusion.com/downloads/support/forum/121667/ze/WebApplication441992847766.zip

Please let us know if you have any concerns.

Thanks,
Alagarsamy D.


JP Jorge Pampin January 18, 2016 09:40 AM UTC

Hello,

Can I use this way to bind the OlapClient control?

Thanks!


JP Jorge Pampin January 18, 2016 11:42 AM UTC

Hello,

And How to pass parameters to the relational service?

Thanks!


RG Ramesh Govindaraj Syncfusion Team January 19, 2016 12:51 PM UTC

Hi Jorge,

Please find the below response.

S.No
Query
Response

1.


Can I use this way to bind the OlapClient control?


No, the OlapClient control doesn’t support relational source. Meanwhile the PivotGrid control has the sample facilities like in OlapClient.



2.


And How to pass parameters to the relational service?


We have prepared a sample where you can pass the parameters from client side(Scripts) to server side(WCF Service) through “customObject”. Please find the sample and code example in the following links.

Sample Link:  http://www.syncfusion.com/downloads/support/forum/121667/ze/WebApplication44165547287

Code:

[Javascript]

    <script type="text/javascript">

        $(function () {

            $("#PivotGrid1").ejPivotGrid({ url: "../wcf/RelationalService.svc", title: "OLAP Browser",beforeServiceInvoke: "beforeserviceinvoke", afterServiceInvoke: "afterserviceinvoke" });

        });


        //This event fires before the service called.

        function beforeserviceinvoke(args) {

            if(args.action=="initialize")     // You can choose the method in WCF Service to send the parameter.

                this.model.customObject = "Your Parameter here";    

        }


        //This event fires after the service called.

        function afterserviceinvoke(args) {

            this.model.customObject = "Your Parameter here";

        }
    </script>

[C#-Inside Service]

        public Dictionary<string, object> InitializeGrid(string action,string customObject)

        {

            //The parameter receives in customObject

            dynamic customData = serializer.Deserialize<dynamic>(customObject.ToString());

          

            /////
        }



Regards,
Ramesh G.


JP Jorge Pampin January 19, 2016 04:52 PM UTC

Hello,

It works!

But, I have another question. In my application I have a PivotGrid control and a PivotSchemaDesigner control. Initially I want all the field into the "Choose fields to add to report:" PivotSchemaDesigner section, but all unchecked, ie, Initially  the PivotGrid will not have any row field, column field, calculation field... The user will add the fields to the PivotGrid with the PivotSchemaDesigner control. How to do this?

Thanks!


RG Ramesh Govindaraj Syncfusion Team January 20, 2016 12:04 PM UTC

Hi Jorge,

Your requirement can be achievable by binding an empty report under the method “BindDefaultData()”. And we have prepared a sample based on your requirement. Please find the sample in the following link.

Sample Link:  http://www.syncfusion.com/downloads/support/forum/121667/ze/WebApplication44-575399247

Regards,
Ramesh G.


JP Jorge Pampin January 20, 2016 01:02 PM UTC

Hello,

It's ok, but this way the "Choose fields to add to report:" PivotSchemaDesigner section shows all fields of the DataView, and I don't want show all of them, and I want to configure the header text of the fields, the numeric format.... How to configure the fields?

Thanks!


RG Ramesh Govindaraj Syncfusion Team January 21, 2016 10:57 AM UTC

Hi Jorge,

Please find the below response.

S.No
Query
Response

1.


PivotSchemaDesigner section shows all fields of the DataView, and I don't want show all of them


We have prepared a sample where you can hide any fields in PivotTable Field List. Please find the sample and code example in the below links.

Sample Link:  http://www.syncfusion.com/downloads/support/forum/121667/ze/WebApplication44-499798983

Code:

[Javascript]

        function rendersuccess(args)

        {

            for (var i = 0; i < $("#schemaFieldTree ul li a").length; i++) {


                if( $("#schemaFieldTree ul li a")[i].text == "Your field name here")

                {

                    $("#schemaFieldTree ul li")[i].remove();

                }


            }
        }


2.


 I want to configure the header text of the fields, the numeric format.... How to configure the fields?


The field names in PivotTable Field List must be same as that of in the database.

The fields in PivotTable Field List will be used for UI operations like check, uncheck and dragging.

On doing so, we need to fetch new values from database, which would be possible if the name in PivotTable Field List and DB matches. This is the our current behavior.

Regards,
Ramesh G.


JP Jorge Pampin January 21, 2016 05:32 PM UTC

Hello,

And, Can I change the FieldHeader of the fields of the The fields in PivotTable Field List when initialy the PivotReport is empty as the sample?

Thanks!


RG Ramesh Govindaraj Syncfusion Team January 22, 2016 07:24 AM UTC

Hi Jorge,

 

As mentioned in our previous response, the field names in PivotTable Field List must be same as that of in the database. It is possible to modify the field headers but for further operations like check, uncheck, dragging... it isn’t fetching the correct values from database since the names are taken from PivotTable Field List to match the fields in database.

 

Regards,

Ramesh G.


Loader.
Live Chat Icon For mobile
Up arrow icon