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.
Unfortunately, activation email could not send to your email. Please try again.

Pass parameter for know which cube load

Thread ID:

Created:

Updated:

Platform:

Replies:

126403 Oct 13,2016 04:13 PM Oct 21,2016 02:28 AM ASP.NET MVC 5
loading
Tags: PivotClient
Felipe Alves
Asked On October 13, 2016 04:13 PM

Hi, i want pass parameter (string) for know which cube i have to load, 

i was thinking something like:

 @Html.EJ().Olap().OlapClient("OlapClient1").Url("http://192.168.50.141:70//api/OlapClient").Title("Titulos a Pagar").Parameter(stringParameter)

or if have another way for do this, i'll appreciate that

Thanks!

Sastha Prathap Selvamoorthy [Syncfusion]
Replied On October 14, 2016 08:53 AM

Hi Felipe, 
 
You can change the connection string by passing string to an object through the parameter “customObject” to initialize the control. Please find the following sample code snippet that can achieve your requirement. 
 
Here is the code snippet for sending the “customObject” in sample. 
$("#OlapClient").ejOlapClient({ url: "../api/OlapClient", title: "OLAP Browser", displaySettings: { mode: "gridonly" }, customObject: { "cube": "cubeChange" } }); 
 
Here is the code snippet for modified the connectionString using “customObject” in WebAPI controller (Server Side). 
static string connectionString = "Data Source=http://bi.syncfusion.com/olap/msmdpump.dll; Initial Catalog=Adventure Works DW 2008 SE;"; 
 
   ///... 
 
[System.Web.Http.ActionName("InitializeClient")] 
[System.Web.Http.HttpPost] 
public Dictionary<string, object> InitializeClient(Dictionary<string, object> jsonResult) 
{ 
   OlapDataManager DataManager = null; 
   dynamic customData = serializer.Deserialize<dynamic>(jsonResult["customObject"].ToString()); 
   if (customData is Dictionary<string, object> && customData.ContainsKey("report")) 
   { 
     if (customData["cube"] == "cubeChange") 
     { 
         connectionString = // modified your connectionString 
         DataManager = new OlapDataManager(connectionString); 
         DataManager.SetCurrentReport(CreateOlapReport1()); // specify the OlapReport for the modified cube 
     } 
    else 
         DataManager.SetCurrentReport(CreateOlapReport()); 
            }       return olapClientHelper.GetJsonData(jsonResult["action"].ToString(), DataManager, jsonResult["clientParams"].ToString()); 
} 
 
    ///.. 
 
// specify the OlapReport for the modified cube as below example 
 
private OlapReport CreateOlapReport1() 
{ 
    OlapReport olapReport = new OlapReport(); 
    olapReport.Name = "Default Report"; 
    olapReport.CurrentCubeName = "Adventure Works"; 
 
    DimensionElement dimensionElementColumn = new DimensionElement(); 
    //Specifying the Name for the Dimension Element 
    dimensionElementColumn.Name = "Customer"; 
    dimensionElementColumn.AddLevel("Customer Geography", "Country"); 
 
    MeasureElements measureElementColumn = new MeasureElements(); 
    //Specifying the Name for the Measure Element 
    measureElementColumn.Elements.Add(new MeasureElement { Name = "Customer Count" }); 
 
    DimensionElement dimensionElementRow = new DimensionElement(); 
    //Specifying the Dimension Name 
    dimensionElementRow.Name = "Date"; 
    dimensionElementRow.AddLevel("Fiscal", "Fiscal Year"); 
 
    ///Adding Row Members 
    olapReport.SeriesElements.Add(dimensionElementColumn); 
    ///Adding Column Members 
    olapReport.CategoricalElements.Add(dimensionElementRow); 
    ///Adding Measure Element 
    olapReport.CategoricalElements.Add(measureElementColumn); 
    return olapReport; 
} 
 
Regards, 
Sastha Prathap S. 


Felipe Alves
Replied On October 20, 2016 07:53 AM

Hi Sastha,

Can you show me how i do this?

$("#OlapClient").ejOlapClient({ url: "../api/OlapClient", title: "OLAP Browser", displaySettings: { mode: "gridonly" }, customObject: { "cube""cubeChange" } }); 

I understand "Olapclient" it's id from some component, but i want know which is...

If you can show me all code from this part i can finish!

Thanks!

Felipe Alves
Replied On October 20, 2016 09:21 AM

I created at my controller something like


  Dictionary<string, Object > try= new Dictionary<string, Object>();
            

            var s = new {cubeName= "cube", cubeCatalog= "catalog" };
            ewqe.Add("c", s);
            ViewBag.teste = try

But when go to api this viewbag.teste values its empty, just have parameter, but value key its empty

Felipe Alves
Replied On October 20, 2016 12:32 PM

i did here,

Thanks

Sastha Prathap Selvamoorthy [Syncfusion]
Replied On October 21, 2016 02:28 AM

Hi Felipe, 
 
We have prepared a sample where you can change the cube by passing the Cube name through “CustomObject” to server side from sample level itself. Please find the sample code snippet and sample link below for your reference. 
 
Sample Code for passing the CustomObject from sample. 
    @Html.EJ().Olap().OlapClient("PivotClient1").Url(Url.Content("~/api/OlapClient")).Title("OLAP Browser").CustomObject(@ViewBag.test) 
 
Sample Code for passing the CustomObject from controller to Viewpage. 
        public ActionResult Index() 
        { 
            Dictionary<string, object> test = null;//Dictionary datatype 
            test = new Dictionary<string, object>(); 
            test.Add("cube", "Channel Sales"); 
            ViewBag.test = test; 
            return View(); 
        } 
 
 
Regards, 
Sastha Prathap S. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;