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
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
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.
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
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.
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": {
"uri": "https://demos.telerik.com/kendo-ui/service/Northwind.svc/Customers('ALFKI')/Orders"
}
}, "CustomerDemographics": {
"__deferred": {
"uri": "https://demos.telerik.com/kendo-ui/service/Northwind.svc/Customers('ALFKI')/CustomerDemographics"
}
}
VS Mine:
{"Data":[{"FullName":"Lee","TimesheetWorkDateMonthYear":"\/Date(1498831200000)\/","Year":"2017","Month":"July","TimesheetTaskJobnumber":"Overhead","TimesheetWorktype":"NT","TimesheetHours":21.400000000000002,"TimesheetOverhead":"Overhead"}
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