Category / Section
How to send custom parameters to events
1 min read
This knowledge base explains the way to send custom parameter to events. You can just send the parameter as option to the widget on its creation and access it in the widget instance.
In general, any properties sent to the widget on its creation is accessible later via widget’s model property.
For other wrappers, also, we have come up with the same approach by setting up the parameter in the widget’s model and later retrieving from it.
JavaScript Solution
[JS]
<script> $(function () { $("#Spreadsheet").ejSpreadsheet({ customParameter: { cellSave: { foo: "bar" }, cellClick: { baz: "qux" } }, //dummy params cellSave: "cellSave", cellClick: "cellClick" }); }); function cellSave(args) { var parameter = this.model.customParameter.cellSave; } function cellClick(args) { var parameter = this.model.customParameter.cellClick; } </script>
MVC Solution
[CSHTML]
@(Html.EJ().Spreadsheet<ItemDetail>("Spreadsheet").ClientSideEvents(events => events.LoadComplete("loadComplete").CellSave("cellSave").CellClick("cellClick")) ) <script type="text/javascript"> function loadComplete(args) { this.option(customParameter, { cellSave: { foo: "bar" }, cellClick: { baz: "qux" } }); //dummy params } function cellSave(args) { var parameter = this.model.customParameter.cellSave; } function cellClick(args) { var parameter = this.model.customParameter.cellClick; } </script>
ASP Solution
[ASPX]
<ej:Spreadsheet ID="FlatSpreadsheet" runat="server"> <ClientSideEvents LoadComplete="loadComplete" CellSave="cellSave" CellClick="cellClick"/> </ej:Spreadsheet> <script type="text/javascript"> function loadComplete(args) { this.option(customParameter, { cellSave: { foo: "bar" }, cellClick: { baz: "qux" } }); //dummy params } function cellSave(args) { var parameter = this.model.customParameter.cellSave; } function cellClick(args) { var parameter = this.model.customParameter.cellClick; } </script>