How to pass information from client to server side in MVC PivotChart?
This KB illustrates how to pass additional information from client-side to server-side.
Solution
You can pass the cube name or any other additional information to the control through custom object. The following code example explains this.
JS
<div> <select id="cube"> <option value="Adventure">Adventure</option> <option value="Mined">Mined</option> </select> </div> <script type="text/javascript"> $("#PivotChart").ejPivotChart({ url: "../wcf/OlapChartService.svc" }); $(function () { $("#cube").ejDropDownList({ fields: { text: "option" }, width: "100px" }); ddlTarget = $('#cube').data("ejDropDownList"); ddlTarget.setSelectedText(ddlTarget.items[0].innerHTML); $("#cube").ejDropDownList("option", "change", "CubeChange"); }); function CubeChange(args) { $("#PivotChart").remove(); var chartpanel = ej.buildTag("div#OlapChart")[0].outerHTML; $(chartpanel).appendTo(".control"); $("#PivotChart").ejPivotChart({ url: "../wcf/OlapChartService.svc", customObject: { CubeName: args.value } }); } </script>
MVC
<div> <select id="cube"> <option value="Adventure">Adventure</option> <option value="Mined">Mined</option> </select> </div> <div class="control"> @Html.EJ().Pivot().PivotChart("PivotChart").Url(Url.Content("~/wcf/OlapChartService.svc")) </div> <script> $(function () { $("#cube").ejDropDownList({ fields: { text: "option" }, width: "100px" }); ddlTarget = $('#cube').data("ejDropDownList"); ddlTarget.setSelectedText(ddlTarget.items[0].innerHTML); $("#cube").ejDropDownList("option", "change", "CubeChange"); }); function CubeChange(args) { $("#PivotChart").remove(); var chartpanel = ej.buildTag("div#PivotChart")[0].outerHTML; $(chartpanel).appendTo(".control"); $("#PivotChart").ejPivotChart({ url: "../wcf/OlapChartService.svc", customObject: { CubeName: args.value } }); } </script>
ASP.NET
<div> <select id="cube"> <option value="Adventure">Adventure</option> <option value="Mined">Mined</option> </select> </div> <ej:PivotChart ID="PivotChart" runat="server" Url="../wcf/OlapChartService.svc"></ej:PivotChart> <script> $(function () { $("#cube").ejDropDownList({ fields: { text: "option" }, width: "100px" }); ddlTarget = $('#cube').data("ejDropDownList"); ddlTarget.setSelectedText(ddlTarget.items[0].innerHTML); $("#cube").ejDropDownList("option", "change", "CubeChange"); }); function CubeChange(args) { $("#PivotChart").remove(); var chartpanel = ej.buildTag("div#PivotChart")[0].outerHTML; $(chartpanel).appendTo(".control"); $("#PivotChart").ejOlapChart({ url: "../wcf/OlapChartService.svc", customObject: { CubeName: args.value } }); } </script>
Conclusion
I hope you enjoyed learning how to pass additional information from the client side to the server side.
You can refer to our ASP.NET MVC PivotChart feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our ASP.NET MVC PivotChart example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!