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. Image for the cookie policy date
close icon

Pass parameter for know which cube load

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("").Title("Titulos a Pagar").Parameter(stringParameter)

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


5 Replies

SP Sastha Prathap Selvamoorthy Syncfusion Team October 14, 2016 12:53 PM UTC

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;"; 
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 
            }       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 
    ///Adding Column Members 
    ///Adding Measure Element 
    return olapReport; 
Sastha Prathap S. 

FA Felipe Alves October 20, 2016 11:53 AM UTC

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!


FA Felipe Alves October 20, 2016 01:21 PM UTC

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

FA Felipe Alves October 20, 2016 04:32 PM UTC

i did here,


SP Sastha Prathap Selvamoorthy Syncfusion Team October 21, 2016 06:28 AM UTC

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(); 
Sastha Prathap S. 

Live Chat Icon For mobile
Up arrow icon