SpreadsheetOptionsExtensions.RegisterGlobalCustomFunction(SpreadsheetOptions, ICustomFunction) Method
Registers the specified global custom function.
Namespace: DevExpress.AspNetCore
Assembly: DevExpress.AspNetCore.Spreadsheet.v25.1.dll
NuGet Package: DevExpress.AspNetCore.Spreadsheet
Declaration
public static SpreadsheetOptions RegisterGlobalCustomFunction(
this SpreadsheetOptions spreadsheetOptions,
ICustomFunction customFunction
)
Parameters
| Name | Type | Description |
|---|---|---|
| spreadsheetOptions | SpreadsheetOptions | Spreadsheet options. |
| customFunction | ICustomFunction | A custom function. |
Returns
| Type | Description |
|---|---|
| SpreadsheetOptions | An object that can be used to further configure the Spreadsheet options. |
Remarks
Follow the steps below to create a custom function.
- Create a class that implements the ICustomFunction interface and performs calculations.
- Pass an instance of the class to the static
RegisterGlobalCustomFunctionmethod as a parameter.
The example below demonstrates how to create a custom function:
builder.Services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
builder.Services.AddDevExpressControls(options => {
options.AddSpreadsheet( spreadsheetOptions => {
spreadsheetOptions
.RegisterGlobalCustomFunction(new MyFunc());
});
});
To make a custom function available in Intellisense, add a description for this function on the client:
<script>
function onInit(s, e){
ASPxClientSpreadsheet.Functions.push({ name: "MYFUNC", description: "My Custom Function", arguments: [ { name: "string", description: "add some string parameter" } ] });
}
</script>
@(Html.DevExpress()
.Spreadsheet("spreadsheet")
.ClientSideEvents(e => {
e.OnInit("onInit");
})
)
See Also