C# (Inside service): private OlapReport CreateOlapReport() { OlapReport olapReport = new OlapReport(); olapReport.Name = "Customer Report"; olapReport.CurrentCubeName = "Adventure Works"; DimensionElement dimensionElementColumn = new DimensionElement(); dimensionElementColumn.Name = "Customer"; dimensionElementColumn.HierarchyName = "Customer Geography"; dimensionElementColumn.AddLevel("Customer Geography", "Country"); MeasureElements measureElementColumn = new MeasureElements(); measureElementColumn.Elements.Add(new MeasureElement { Name = "Internet Sales Amount" }); DimensionElement dimensionElementRow = new DimensionElement(); dimensionElementRow.Name = "Date"; dimensionElementRow.AddLevel("Fiscal", "Fiscal Year"); //Framing excluded dimension. DimensionElement excludedElement = new DimensionElement(); excludedElement.Name = "Date"; excludedElement.HierarchyName = "Fiscal"; excludedElement.AddLevel("Fiscal", "Fiscal Year"); //Getting members from hierarchy. string memberMdxQuery = "SELECT ADDCALCULATEDMEMBERS({" + excludedElement.HierarchyName + ".CHILDREN}) DIMENSION PROPERTIES MEMBER_NAME, MEMBER_TYPE ON 0, {} ON 1 FROM [" + olapReport.CurrentCubeName + "]"; MASAC.AdomdConnection adomdConnectionObjMain = null; adomdConnectionObjMain = new MASAC.AdomdConnection(@"Data Source=http://bi.syncfusion.com/olap/msmdpump.dll; Initial Catalog=Adventure Works DW 2008 SE;"); adomdConnectionObjMain.Open(); Microsoft.AnalysisServices.AdomdClient.CellSet set = new Microsoft.AnalysisServices.AdomdClient.AdomdCommand(memberMdxQuery, adomdConnectionObjMain).ExecuteCellSet(); MASAC.Axis memberCollection = set.Axes[0]; //Adding members in excludedElement for (int i = 0; i < memberCollection.Positions.Count; i++) { if (memberCollection.Positions[i].Members[0].Caption != "FY 2003") excludedElement.Hierarchy.LevelElements["Fiscal Year"].Add(new MemberElement { Name = memberCollection.Positions[i].Members[0].Caption, UniqueName = memberCollection.Positions[i].Members[0].UniqueName }); } olapReport.CategoricalElements.Add(dimensionElementColumn); olapReport.CategoricalElements.Add(measureElementColumn); ///Adding excludedElement in Row section of OlapReport olapReport.SeriesElements.Add(dimensionElementRow, excludedElement); return olapReport; } |
private OlapReport CreateOlapReport() { OlapReport olapReport = new OlapReport(); olapReport.Name = "Company Sales"; olapReport.CurrentCubeName = "Blue Streak Sales"; DimensionElement dimensionElementColumn = new DimensionElement(); dimensionElementColumn.Name = "Stores"; dimensionElementColumn.HierarchyName = "Stores"; dimensionElementColumn.AddLevel("Company", "Company"); MeasureElements measureElementColumn = new MeasureElements(); measureElementColumn.Elements.Add(new MeasureElement { Name = "Amount" }); DimensionElement dimensionElementRow = new DimensionElement(); dimensionElementRow.Name = "Date"; dimensionElementRow.AddLevel("Year", "Year"); //Framing excluded dimension. DimensionElement excludedElement = new DimensionElement(); excludedElement.Name = "Date"; excludedElement.HierarchyName = "Date"; excludedElement.AddLevel("Year", "Year"); //Getting members from hierarchy. string memberMdxQuery = "SELECT ADDCALCULATEDMEMBERS({" + excludedElement.HierarchyName + ".CHILDREN}) DIMENSION PROPERTIES MEMBER_NAME, MEMBER_TYPE ON 0, {} ON 1 FROM [" + olapReport.CurrentCubeName + "]"; MASAC.AdomdConnection adomdConnectionObjMain = null; adomdConnectionObjMain = new MASAC.AdomdConnection(connectionString); adomdConnectionObjMain.Open(); Microsoft.AnalysisServices.AdomdClient.CellSet set = new Microsoft.AnalysisServices.AdomdClient.AdomdCommand(memberMdxQuery, adomdConnectionObjMain).ExecuteCellSet(); MASAC.Axis memberCollection = set.Axes[0]; //Adding members in excludedElement for (int i = 0; i < memberCollection.Positions.Count; i++) { if (memberCollection.Positions[i].Members[0].Caption != "2016") excludedElement.Hierarchy.LevelElements["Year"].Add(new MemberElement { Name = memberCollection.Positions[i].Members[0].Caption, UniqueName = memberCollection.Positions[i].Members[0].UniqueName }); } olapReport.CategoricalElements.Add(dimensionElementColumn); olapReport.CategoricalElements.Add(measureElementColumn); ///Adding excludedElement in Row section of OlapReport olapReport.SeriesElements.Add(dimensionElementRow, excludedElement); return olapReport; } |
DimensionElement dimensionElementColumn = new DimensionElement(); dimensionElementColumn.Name = "Date"; dimensionElementColumn.HierarchyName = "Date"; dimensionElementColumn.AddLevel("Year", "Year"); MeasureElements measureElementColumn = new MeasureElements(); measureElementColumn.Elements.Add(new MeasureElement { Name = "Amount" }); DimensionElement dimensionElementRow = new DimensionElement(); dimensionElementRow.Name = "Stores"; dimensionElementRow.AddLevel("Company", "Company"); //Framing excluded dimension. DimensionElement excludedElement = new DimensionElement(); excludedElement.Name = "Stores"; excludedElement.HierarchyName = "Stores"; excludedElement.AddLevel("Company", "Company"); |
{"Message":"An error has occurred.","ExceptionMessage":"Object reference not set to an instance of an object.","ExceptionType":"System.NullReferenceException","StackTrace":" at BlueStreakReporting.WebAPI.OlapGridController.CreateOlapReport() in C:\\Users\\administrator.BLUESTREAK\\Documents\\Syncfusion MVC\\Projects\\BlueStreakReporting\\WebAPI\\OlapGridController.cs:line 224\r\n at BlueStreakReporting.WebAPI.OlapGridController.InitializeOlapGrid(Dictionary`2 jsonResult) in C:\\Users\\administrator.BLUESTREAK\\Documents\\Syncfusion MVC\\Projects\\BlueStreakReporting\\WebAPI\\OlapGridController.cs:line 35\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"} |
//Adding members in excludedElement for (int i = 0; i < memberCollection.Positions.Count; i++) { if (memberCollection.Positions[i].Members[0].Caption != "4") excludedElement.Hierarchy.LevelElements["Company"].Add(new MemberElement { Name = memberCollection.Positions[i].Members[0].Caption, UniqueName = memberCollection.Positions[i].Members[0].UniqueName }); } |
private OlapReport CreateOlapReport() { OlapReport olapReport = new OlapReport(); olapReport.Name = "Company Sales"; olapReport.CurrentCubeName = "Blue Streak Sales"; DimensionElement dimensionElementColumn = new DimensionElement(); dimensionElementColumn.Name = "Stores"; dimensionElementColumn.AddLevel("Company", "Company"); MeasureElements measureElementColumn = new MeasureElements(); measureElementColumn.Elements.Add(new MeasureElement { Name = "Amount" }); DimensionElement dimensionElementRow = new DimensionElement(); dimensionElementRow.Name = "Date"; dimensionElementRow.AddLevel("Year", "Year"); //Opening adomd connection. MASAC.AdomdConnection adomdConnectionObjMain = null; adomdConnectionObjMain = new MASAC.AdomdConnection(connectionString); adomdConnectionObjMain.Open(); //Framing excluded dimension “Date”. DimensionElement excludedElement = new DimensionElement(); excludedElement.Name = "Date"; excludedElement.AddLevel("Year", "Year"); //Getting members from hierarchy “Year”. string memberMdxQuery = "SELECT ADDCALCULATEDMEMBERS({" + excludedElement.Hierarchy.UniqueName + ".CHILDREN}) DIMENSION PROPERTIES MEMBER_NAME, MEMBER_TYPE ON 0, {} ON 1 FROM [" + olapReport.CurrentCubeName + "]"; Microsoft.AnalysisServices.AdomdClient.CellSet set = new Microsoft.AnalysisServices.AdomdClient.AdomdCommand(memberMdxQuery, adomdConnectionObjMain).ExecuteCellSet(); MASAC.Axis memberCollection = set.Axes[0]; //Adding members in excludedElement for (int i = 0; i < memberCollection.Positions.Count; i++) { if (memberCollection.Positions[i].Members[0].Caption != "2013") excludedElement.Hierarchy.LevelElements["Year"].Add(new MemberElement { Name = memberCollection.Positions[i].Members[0].Caption, UniqueName = memberCollection.Positions[i].Members[0].UniqueName }); } //Framing excluded dimension “Stores”. DimensionElement excludedElementCol = new DimensionElement(); excludedElementCol.Name = "Stores"; excludedElementCol.AddLevel("Company", "Company"); //Getting members from hierarchy “Company”. memberMdxQuery = "SELECT ADDCALCULATEDMEMBERS({" + excludedElementCol.Hierarchy.UniqueName + ".CHILDREN}) DIMENSION PROPERTIES MEMBER_NAME, MEMBER_TYPE ON 0, {} ON 1 FROM [" + olapReport.CurrentCubeName + "]"; set = new Microsoft.AnalysisServices.AdomdClient.AdomdCommand(memberMdxQuery, adomdConnectionObjMain).ExecuteCellSet(); memberCollection = set.Axes[0]; //Adding members in excludedElement for (int i = 0; i < memberCollection.Positions.Count; i++) { if (memberCollection.Positions[i].Members[0].Caption != "Freshii") excludedElementCol.Hierarchy.LevelElements["Company"].Add(new MemberElement { Name = memberCollection.Positions[i].Members[0].Caption, UniqueName = memberCollection.Positions[i].Members[0].UniqueName }); } ///Adding excludedElement for the dimension “Stores” olapReport.CategoricalElements.Add(dimensionElementColumn, excludedElementCol); olapReport.CategoricalElements.Add(measureElementColumn); ///Adding excludedElement for the dimension “Date” olapReport.SeriesElements.Add(dimensionElementRow, excludedElement); return olapReport; } |
OlapDataManager DataManager = new OlapDataManager(@"Data Source=http://bi.syncfusion.com/olap/msmdpump.dll; Roles=Role1; Initial Catalog=Adventure Works DW 2008 SE;"); |
<script type="text/javascript">
var pivotClient;
$(function () {
$("#PivotClient").ejPivotClient({ url: '../api/OlapClient', renderSuccess:"memberEditorFilter" });
});
function memberEditorFilter(args) {
pivotClient = $("#PivotClient").data("ejPivotClient");
var excludeElements = ["FY 2003", "FY 2004"]; // Specify the excluded elements
if (!ej.isNullOrUndefined(pivotClient.memberTreeObj))
if (pivotClient.memberTreeObj.dataSource().length > 0) {
var liList = JSON.stringify(pivotClient.memberTreeObj.dataSource());
liList = JSON.parse(liList);
$.each(excludeElements, function (e, excludeElement) {
for (i = 0; i < liList.length; i++) {
if (liList[i].name.length > 0 && liList[i].name == excludeElement)
$(pivotClient.element.find(".editorTreeView ul li")[i]).hide();
}
for (j = 0; j < pivotClient.memberTreeObj.dataSource().length; j++) {
if (pivotClient.memberTreeObj.dataSource()[j].name == excludeElement)
pivotClient.memberTreeObj.dataSource().splice(j, 1);
}
});
}
}
</script> |
@Html.EJ().Pivot().PivotGrid("PivotGrid1").Url(Url.Content("~/api/OlapGrid")).ClientSideEvents(events => events.AfterServiceInvoke("OnAfterServiceInvoke")).EnableGroupingBar(true)
<script type="text/javascript">
OnAfterServiceInvoke = function (evt) {
pivotGrid = $("#PivotGrid1").data("ejPivotGrid");
var excludeElements = ["FY 2002", "FY 2003"]; // Specify the excluded elements
if (!ej.isNullOrUndefined(pivotGrid._memberTreeObj))
if (pivotGrid._memberTreeObj.dataSource().length > 0) {
var liList = JSON.stringify(pivotGrid._memberTreeObj.dataSource());
liList = JSON.parse(liList);
$.each(excludeElements, function (e, excludeElement) {
for (i = 0; i < liList.length; i++) {
if (liList[i].name.length > 0 && liList[i].name == excludeElement)
$(pivotGrid.element.find("#editorTreeView ul li")[i]).hide();
}
for (j = 0; j < pivotGrid._memberTreeObj.dataSource().length; j++) {
if (pivotGrid._memberTreeObj.dataSource()[j].name == excludeElement)
pivotGrid._memberTreeObj.dataSource().splice(j, 1);
}
});
}
}
</script> |
@Html.EJ().Pivot().PivotGrid("PivotGrid1").Url(Url.Content("~/api/OlapGrid")).ClientSideEvents(events => events.AfterServiceInvoke("OnAfterServiceInvoke")).EnableGroupingBar(true)
@Html.EJ().Pivot().PivotSchemaDesigner("PivotSchemaDesigner").Layout(PivotSchemaDesignerLayout.Excel).ClientSideEvents(events => events.AfterServiceInvoke("OnAfterServiceInvoke1"))
<script type="text/javascript">
OnAfterServiceInvoke = function (evt) {
if (evt.action == "initialize") {
var PivotSchemaDesigner = $("#PivotSchemaDesigner").data('ejPivotSchemaDesigner');
if (PivotSchemaDesigner.model.pivotControl == null) {
PivotSchemaDesigner.model.pivotControl = this;
PivotSchemaDesigner.model.enableWrapper = true;
PivotSchemaDesigner.model.layout = "excel";
PivotSchemaDesigner._load();
}
}
}
function OnAfterServiceInvoke1(args) {
pivotSchema = $("#PivotSchemaDesigner").data("ejPivotSchemaDesigner")
var excludeElements = ["FY 2002", "FY 2003"]; // Specify the excluded elements
if (!ej.isNullOrUndefined(pivotSchema._currentMembers))
if (JSON.parse(pivotSchema._currentMembers).length > 0) {
var liList = JSON.parse(pivotSchema._currentMembers);
$.each(excludeElements, function (e, excludeElement) {
for (j = 0; j < liList.length; j++) {
if (liList[j].name == excludeElement)
liList.splice(j, 1);
}
});
pivotSchema._currentMembers = JSON.stringify(liList);
}
}
</script> |
@Html.EJ().Pivot().PivotGrid("PivotGrid1").EnableGrandTotal(false).EnableDeferUpdate(true).IsResponsive(true).EnableConditionalFormatting(true).Url(Url.Content("~/api/OLAPGrid")).ClientSideEvents(events => events.AfterServiceInvoke("OnAfterServiceInvoke").RenderSuccess("renderSuccess")).EnableGroupingBar(true) @Html.EJ().Pivot().PivotSchemaDesigner("PivotSchemaDesigner").Layout(PivotSchemaDesignerLayout.Excel).ClientSideEvents(events => events.AfterServiceInvoke("OnAfterServiceInvoke1")) <script> function OnAfterServiceInvoke(evt) { if (evt.action == "initialize") { var PivotSchemaDesigner = $("#PivotSchemaDesigner").data('ejPivotSchemaDesigner'); if (PivotSchemaDesigner.model.pivotControl == null) { PivotSchemaDesigner.model.pivotControl = this; PivotSchemaDesigner.model.enableWrapper = true; PivotSchemaDesigner.model.layout = "excel"; PivotSchemaDesigner._load(); } } } function OnAfterServiceInvoke1(args) { pivotSchema = $("#PivotSchemaDesigner").data("ejPivotSchemaDesigner") var excludeElements = ["Bakewell","Coldstone"]; // Specify the excluded elements if (!ej.isNullOrUndefined(pivotSchema._currentMembers)) if (JSON.parse(pivotSchema._currentMembers).length > 0) { var liList = JSON.parse(pivotSchema._currentMembers); $.each(excludeElements, function (e, excludeElement) { for (j = 0; j < liList.length; j++) { if (liList[j].name == excludeElement) liList.splice(j, 1); } }); pivotSchema._currentMembers = JSON.stringify(liList); } } </script> |
@Html.EJ().Pivot().PivotGrid("PivotGrid1").Url(Url.Content("~/api/OlapGrid")).ClientSideEvents(events => events.AfterServiceInvoke("OnAfterServiceInvoke")).EnableGroupingBar(true)
@Html.EJ().Pivot().PivotSchemaDesigner("PivotSchemaDesigner").Layout(PivotSchemaDesignerLayout.Excel).ClientSideEvents(events => events.AfterServiceInvoke("OnAfterServiceInvoke1"))
<script type="text/javascript">
OnAfterServiceInvoke = function (evt) {
if (evt.action == "initialize") {
var PivotSchemaDesigner = $("#PivotSchemaDesigner").data('ejPivotSchemaDesigner');
if (PivotSchemaDesigner.model.pivotControl == null) {
PivotSchemaDesigner.model.pivotControl = this;
PivotSchemaDesigner.model.enableWrapper = true;
PivotSchemaDesigner.model.layout = "excel";
PivotSchemaDesigner._load();
}
}
pivotGrid = $("#PivotGrid1").data("ejPivotGrid");
var excludeElements = ["FY 2002", "FY 2003"]; // Specify the excluded elements for PivotGrid with GroupingBar
if (!ej.isNullOrUndefined(pivotGrid._memberTreeObj))
if (pivotGrid._memberTreeObj.dataSource().length > 0) {
var liList = JSON.stringify(pivotGrid._memberTreeObj.dataSource());
liList = JSON.parse(liList);
$.each(excludeElements, function (e, excludeElement) {
for (i = 0; i < liList.length; i++) {
if (liList[i].name.length > 0 && liList[i].name == excludeElement)
$(pivotGrid.element.find("#editorTreeView ul li")[i]).hide();
}
for (j = 0; j < pivotGrid._memberTreeObj.dataSource().length; j++) {
if (pivotGrid._memberTreeObj.dataSource()[j].name == excludeElement)
pivotGrid._memberTreeObj.dataSource().splice(j, 1);
}
});
}
}
function OnAfterServiceInvoke1(args) {
pivotSchema = $("#PivotSchemaDesigner").data("ejPivotSchemaDesigner")
var excludeElements = ["FY 2002", "FY 2003"]; // Specify the excluded elements for PivotGrid with PivotSchemadesigner
if (!ej.isNullOrUndefined(pivotSchema._currentMembers))
if (JSON.parse(pivotSchema._currentMembers).length > 0) {
var liList = JSON.parse(pivotSchema._currentMembers);
$.each(excludeElements, function (e, excludeElement) {
for (j = 0; j < liList.length; j++) {
if (liList[j].name == excludeElement)
liList.splice(j, 1);
}
});
pivotSchema._currentMembers = JSON.stringify(liList);
}
}
</script> |