This is a migrated thread and some comments may be shown as answers.

Multipule "Views" one PivotGrid

8 Answers 16 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
Lee
Top achievements
Rank 1
Veteran
Lee asked on 28 Mar 2018, 01:30 AM

Hi,

Is it possible to use 1 PivotGrid and have pre-defined columns, rows and measures etc, that change based on an onclick event?

For instance i would have two buttons, "View 1" and "View 2", when one of these buttons are clicked the PivotGrid would re-drawn using defined cols, rows etc?

Thanks,
Lee.

8 Answers, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 29 Mar 2018, 02:02 PM
Hi Lee,

You should be able to achieve this with the approach shown in the following example:
Reload PivotGrid Configuration Options

By updating the DataSource configuration and assigning a new DataSource with the new options to the PivotGrid, you will be able to change the list of columns, measures, etc.

Regards,
Tsvetina
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Lee
Top achievements
Rank 1
Veteran
answered on 30 Mar 2018, 06:17 AM
Fantastic! I'll give that a go!
0
Lee
Top achievements
Rank 1
Veteran
answered on 03 Apr 2018, 07:47 AM

Hi Tsvetina,

I can't seem to get this to work, i'm not sure if it's because i'm trying to use ajax and not the xmla.

Is this possible using the Ajax version?

I get undefined values everywhere, i'm currently using the same endpoint i would use when using the MVC asp.net version (works) with the 'ToDataSourceResult'

For the moment until i figure it out i'm using tabs with multiple pivotgrids and i also have issues there: https://www.telerik.com/forums/multipule-pivotgrids-(8)-not-loading-correctly

Thanks,
Lee.

0
Tsvetina
Telerik team
answered on 04 Apr 2018, 02:27 PM
Hello Lee,

I tried with a DataSource bound to a regular OData service and it still worked:
https://dojo.telerik.com/APaROzip

Maybe I am missing something important about your scenario. Can you modify the Dojo to reproduce your case? Or are you actually using the MVC PivotGrid? 

Regards,
Tsvetina
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Lee
Top achievements
Rank 1
Veteran
answered on 04 Apr 2018, 08:20 PM

Thanks Tsvetina,

I'm not able to view it as your certificate has expired:

dojo.telerik.com uses an invalid security certificate. The certificate expired on Wednesday, April 4, 2018, 11:00 PM. The current time is Thursday, April 5, 2018, 6:17 AM. Error code: SEC_ERROR_EXPIRED_CERTIFICATE

 

Yeah i am currently using the MVC Grid but happy to switch to the javascript version, as long as the same is achievable, i.e. via Ajax "ToDataSourceResult", i'll try your newest solution once the certificate issue has been fixed.

0
Lee
Top achievements
Rank 1
Veteran
answered on 04 Apr 2018, 08:26 PM

I looked at your example, but this is using a different data structure to the "ToDataSourceResult" how can i implement this while using the "ToDataSourceResult"

Yours:

jQuery1124013099836514038143_1522873245006({
"d" : {
"results": [
{
"__metadata": {
"uri": "https://demos.telerik.com/kendo-ui/service/Northwind.svc/Customers('ALFKI')", "type": "SampleModel.Customer"
}, "CustomerID": "ALFKI", "CompanyName": "Alfreds Futterkiste", "ContactName": "Maria Anders", "ContactTitle": "Sales Representative", "Address": "Obere Str. 57", "City": "Berlin", "Region": null, "PostalCode": "12209", "Country": "Germany", "Phone": "030-0074321", "Fax": "030-0076545", "Bool": null, "Orders": {
"__deferred": {
}
}, "CustomerDemographics": {
"__deferred": {
}
}

 

VS Mine:

{"Data":[{"FullName":"Lee","TimesheetWorkDateMonthYear":"\/Date(1498831200000)\/","Year":"2017","Month":"July","TimesheetTaskJobnumber":"Overhead","TimesheetWorktype":"NT","TimesheetHours":21.400000000000002,"TimesheetOverhead":"Overhead"}

 

 

0
Accepted
Tsvetina
Telerik team
answered on 10 Apr 2018, 06:57 AM
Hello Lee,

The difference in the response format is mostly reflected to the way the initial parsing is done, but the rest of the configuration should be similar. When binding your Grid to a response returned as a DataSource result, the DataSource configuration would look like this:
"dataSource":{ 
   "type": "aspnetmvc-ajax",
   "transport":{ 
      "read":{ 
         "url":"/PivotGrid/Customers_Read"
      }
   },
   "rows":[ 
      
         "name":"ContactTitle",
         "expand":true
      }
   ],
   "columns":[ 
      
         "name":"Country",
         "expand":true
      },
      
         "name":"CompanyName"
      }
   ],
   "measures":{ 
      "values":[ 
         
            "name":"Contacts Count"
         }
      ]
   },
   "schema":{ 
      "data":"Data",
      "total":"Total",
      "errors":"Errors",
      "cube":{ 
         "measures":{ 
            "Contacts Count":{ 
               "field":"CustomerID",
               "aggregate":"count"
            }
         },
         "dimensions":{ 
            "ContactName":{ 
               "caption":"All Contacts"
            },
            "CompanyName":{ 
               "caption":"All Companies"
            },
            "Country":{ 
               "caption":"All Countries"
            },
            "ContactTitle":{ 
               "caption":"All Titles"
            }
         }
      },
      "model":{ 
         "fields":{ 
            "CustomerID":{ 
               "type":"string"
            },
            "CompanyName":{ 
               "type":"string"
            },
            "ContactName":{ 
               "type":"string"
            },
            "ContactTitle":{ 
               "type":"string"
            },
            "City":{ 
               "type":"string"
            },
            "Country":{ 
               "type":"string"
            },
            "Bool":{ 
               "type":"boolean",
               "defaultValue":null
            }
         }
      }
   }
}

You can ignore the quotes around options names, I just copied the generated DataSource code from the output of this demo:
PivotGrid / Remote binding
What you see above is pretty much the same script as what is generated by the MVC PivotGrid wrapper for the DataSource, with the exclusion of a couple of less important settings for the sake of simplicity.

Regards,
Tsvetina
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Lee
Top achievements
Rank 1
Veteran
answered on 11 Apr 2018, 09:44 AM
Thank you Tsvetina that fixed it!
Tags
PivotGrid
Asked by
Lee
Top achievements
Rank 1
Veteran
Answers by
Tsvetina
Telerik team
Lee
Top achievements
Rank 1
Veteran
Share this question
or