Save PivotClient Configuration

Hi, I try to save my filters, subtotal for column/row, grandtotal and conditional formatting(enable in PivotClient with your workaround) in my sql table and open pivotclient with my custom config. What should I save on the database to reopen my pivotclient with filters and grid with conditional formatting applied? The preference is to not use your encrypted string in the report. If you can not do it without using it, it does not matter. I await your reply. thank you

This is your workaround to save conditional formatting for grid that you send many weeks ago:

var pivotGridObj; function ApplyChanges() { if (pivotGridObj.model.enableConditionalFormatting) { pivotGridObj.openConditionalFormattingDialog(); } }

$("#Btn1").ejButton({ roundedCorner: true, size: "small", type: ej.ButtonType.Button, click: "ApplyChanges" }); $("#Btn2").ejButton({ roundedCorner: true, size: "small", type: ej.ButtonType.Button, click: "Reset" }); $("#BtnSave").ejButton({ roundedCorner: true, size: "small", type: ej.ButtonType.Button, click: "SaveReport" });


5 Replies

SA Scintilla Arul Jothi Raj Syncfusion Team May 8, 2018 04:06 PM UTC

  
Hi Simone, 
  
Thanks for contacting Syncfusion support. 
  
You can save and reload the conditional format settings along with filters of subtotal for column/row and grand total. This requirement can be achieved by the combination of events - “beforeServiceInvoke” and “renderSuccess” through workaround. Please refer the code snippet below. 
  
Code Snippet: [JavaScript] 
<script> 
  
   var conditionalFormatSettings, reportName, action = false, grandTotal;      
    
function beforeService(args) { 
 var gridObj = $("#PivotClient1_PivotGrid").data("ejPivotGrid"); 
if (args.action == "saveReport") 
{ 
action = true; 
conditionalFormatSettings = gridObj.model.conditionalFormatSettings; 
var reportDropTarget = $('#reportList').data("ejDropDownList"); 
this._clientReportCollection = $.map(this._clientReportCollection, function (item, index) { 
if (reportDropTarget.value() == item.name) { 
item.customData = JSON.stringify(conditionalFormatSettings); 
} 
return item; 
}); 
grandTotal = gridObj.model.enableGrandTotal; 
} 
} 
  
function renderSuccess(args) { 
var reportDropTarget = $('#reportList').data("ejDropDownList"); 
    
var conditionalFromatingInfo = $.map(this._clientReportCollection, function (item, index) { 
if (reportDropTarget.value() == item.name) { 
return item.customData; 
} 
}); 
if (conditionalFromatingInfo.length > 0) { 
args._pivotGrid.model.conditionalFormatSettings = JSON.parse(conditionalFromatingInfo[0]); 
} 
} 
} 
</script> 
  
 
  
Code Snippet: [cshtml] 
@Html.EJ().Pivot().PivotClient("PivotClient1”).ClientSideEvents(oEve => { oEve. RenderSuccess("renderSuccess").BeforeServiceInvoke("beforeService"); }) 
 
  
Meanwhile, we have prepared sample for your reference. Please find the sample in the below link. 
  
Regards, 
Scintilla A 



SI Simone May 14, 2018 08:56 AM UTC

I'm testing conditional formatting settings save. Meantime I want to ask you a problem with subtotals saving. Can I apply my subtotal setting (my boolean value) to actually pivotGrid model into render success method of pivotClient? I don't undestand this.

Thank you. 
Simone


SA Scintilla Arul Jothi Raj Syncfusion Team May 15, 2018 12:22 PM UTC

Hi Simone, 

We cannot hide subtotals in the PivotGrid model for relational data at server mode instead we can hide subtotals in the PivotEngine at server side itself. Please refer the code snippet below. 

Code Snippet: [C#] 

private PivotReport BindDefaultData() 
{ 
PivotReport pivotSetting = new PivotReport(); 
 
pivotSetting.PivotRows.Add(new PivotItem { FieldMappingName = "Date", FieldHeader = "Date", TotalHeader = "Total", ShowSubTotal = false }); 
 
pivotSetting.PivotRows.Add(new PivotItem { FieldMappingName = "Product", FieldHeader = "Product", TotalHeader = "Total", ShowSubTotal = true }); 
 
pivotSetting.PivotColumns.Add(new PivotItem { FieldMappingName = "Country", FieldHeader = "Country", TotalHeader = "Total", ShowSubTotal = false }); 
 
pivotSetting.PivotCalculations.Add(new PivotComputationInfo { CalculationName = "Amount", Description = "Amount", FieldHeader = "Amount", FieldName = "Amount", Format = "C", SummaryType = Syncfusion.PivotAnalysis.Base.SummaryType.DoubleTotalSum }); 
 
return pivotSetting; 
 
} 
 

Please find the below documentation link to know more details about hiding subtotals. 

 
Please let us know if you have any concerns. 
 
Regards, 
Scintilla A 



SI Simone May 15, 2018 02:40 PM UTC

Is there a way to hide when client side ? 



SA Scintilla Arul Jothi Raj Syncfusion Team May 16, 2018 12:41 PM UTC

  
Hi Simone,   
  
Currently we don’t have any API's on the client-side to hide sub-totals. As mentioned earlier, it can be hidden only by setting “showSubtotal” property in controller while binding report.   
  
Regards,   
Scintilla A.    


Loader.
Up arrow icon