Calls back to the ASPX page with the specified command.
Syntax
[JavaScript]
FpSpread1.CallBack(cmd, asyncCallBack);
Parameters
- cmd
- String, the command to post back
See the list of reserved commands below - asyncCallBack
- Boolean, whether to allow an asynchronous callback
Reserved Commands
The following pre-defined commands are built into Spread. These are reserved command names; do not use these names for any custom commands that you create, as Spread ignores the custom definition and uses the built-in definition. Not all the commands have corresponding events.
Reserved Command Name |
Corresponding FpSpread Event |
Description |
---|---|---|
ActiveSpread |
- - |
reserved for internal use for down-level browsers; makes a specified Spread component the active component |
Add |
adds a row and raises the event |
|
Cancel |
cancels the operation and raises the event |
|
CellClick |
clicks a cell using the left mouse button |
|
Chart |
- - |
used with Chart control |
ChildView |
displays a specified child view when the HierarchicalView property is set to False and raises the event |
|
Color |
used in filter feature |
|
ColumnHeaderClick |
same as click in column header and raises the event |
|
Date |
used in filter feature |
|
Delete |
deletes a row and raises the event |
|
Edit |
same as Edit button and raises the event |
|
ExpandView |
expands or collapses a specified row; raises the event; when row is expanded to display a child view, raises the ChildViewCreated event |
|
Filter$reset |
- - |
clears the filter in the specified column |
First |
moves to the first page on the sheet |
|
Group |
groups the rows |
|
GroupBar |
used for the group bar |
|
Icon |
used in filter feature |
|
Insert |
adds a row at a particular place and raises the event |
|
Last |
moves to the last page on the sheet |
|
LoadOnDemand |
- - |
loads rows as needed |
Menu |
used with context menu |
|
MoveCol |
- - |
moves the column |
MultiValues |
used in filter feature |
|
Next |
moves to the next page on the sheet |
|
Number |
used in filter feature |
|
Page |
moves to a specified page on the sheet |
|
Prev |
moves to the previous page on the sheet |
|
|
prints the sheet |
|
PrintPDF |
prints the sheet to a PDF document |
|
RefreshChart |
- - |
used with Chart control |
Regroup |
groups the rows again |
|
RetrieveFilterBarMenus | - - | used in dynamic mode for the filter bar |
RowHeaderClick |
clicks a cell in the row header |
|
ScrollDownToPage |
moves down a page |
|
ScrollUpToPage |
moves up a page |
|
Select |
reserved for internal use for down-level browsers; selects a specified row |
|
SelectView |
moves to a specified sheet |
|
SortAZ |
- - |
sorts the column in ascending order |
SortColumn |
sorts a column |
|
SortZA |
- - |
sorts the column in descending order |
TabLeft |
- - |
displays the previous sheet tabs to the left |
TabRight |
- - |
displays the next sheet tabs to the right |
Text |
used in filter feature |
|
Top10 |
used in filter feature |
|
Ungroup |
removes the group |
|
Update |
saves the changes |
|
UpdateValues |
- - |
used when FpSpread.ClientAutoCalculation is True; Spread updates its calculated value immediately after the user enters a formula |
For those commands that correspond with command events in FpSpread, using these commands with the CallBack function basically behaves the same as if you had clicked the appropriate command bar button.
The ChildView command looks like this:
FpSpread1.CallBack("ChildView,relationname")
where relationname is the name of the relation you are trying to view.
The ExpandView command looks like this:
FpSpread1.CallBack("ExpandView,rownum")
where rownum is the zero-indexed row number to expand. For example, a rownum of 2 expands the third row of the parent sheet (since row indexes are zero-indexed). If you want to expand a row below the parent sheet level, you have to know the name of the sheet at that level. This code expands the fourth row at the particular level in the hierarchy:
function DoCallBack() { var ss = event.spread; ss.CallBack("ExpandView,3"); }
The Page command looks like this:
FpSpread1.CallBack("Page,pagenum")
where pagenum is the zero-indexed page number on the active sheet. For example, a pagenum of 2 scrolls to the third page on the active sheet, since the sheets are zero-indexed.
Custom Commands
If you use a string to define a CallBack with a command that is not a one of the built-in commands, Spread raises the ButtonCommand event for the Spread component and passes in the name of the custom CallBack command as e.CommandName, as shown in this example code.
In JavaScript:
FpSpread1.CallBack("MyCommand", false)
In corresponding server-side code (Visual Basic .NET):
VB .NET | Copy Code |
---|---|
Private Sub FpSpread1_ButtonCommand(ByVal sender As Object, ByVal e As FarPoint.Web.Spread.SpreadCommandEventArgs) Handles FpSpread1.ButtonCommand If e.CommandName = "MyCommand" Then FpSpread1.Sheets(0).Cells(0, 0).Text = "My Command Worked" End If End Sub |
Return Type
None
Examples
This is a sample that contains the method with one of the built-in commands. On the client side, the script that contains the method would look like this:
JavaScript | Copy Code |
---|---|
<SCRIPT language=javascript> function SortIt() { FpSpread1.CallBack(SortColumn, false); } </SCRIPT> |
This is a sample showing a simple way of programmatically doing an AJAX postback that raises the UpdateCommand event:
JavaScript | Copy Code |
---|---|
<script language="javascript"> function window.onload() { FpSpread1.onDataChanged = DoCallBack; } function DoCallBack() { FpSpread1.UpdatePostbackData(); FpSpread1.CallBack("Update", true); } </SCRIPT> |