Spread ASP.NET 6.0 Product Documentation
CallBack
Send Feedback
Spread ASP.NET 6.0 Product Documentation > Client-Side Scripting Reference > Scripting Members > Methods > CallBack

Glossary Item Box

Calls back to the ASPX page with the specified command.

Syntax

[JavaScript]

FpSpread1.CallBack(cmd);

Parameters

cmd
String, the command to post back
See the list of reserved commands below

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

InsertCommand

adds a row and raises the event

Cancel

CancelCommand

cancels the operation and raises the event

CellClick

CellClick

clicks a cell using the left mouse button

ChildView

ChildViewCreated

displays a specified child view when the HierarchicalView property is set to False and raises the event

ColumnHeaderClick

ColumnHeaderClick

same as click in column header and raises the event

Delete

DeleteCommand

deletes a row and raises the event

Edit

EditCommand

same as Edit button and raises the event

ExpandView

ChildViewCreated

expands or collapses a specified row; raises the event; when row is expanded to display a child view, raises the ChildViewCreated event

Insert

InsertCommand

adds a row at a particular place and raises the event

Next

- -

moves to the next page on the sheet

Page

- -

moves to a specified page on the sheet

Prev

- -

moves to the previous page on the sheet

RowHeaderClick

RowHeaderClick

clicks a cell in the row header

Select

- -

reserved for internal use for down-level browsers; selects a specified row

SelectView

- -

moves to a specified sheet

SortColumn

SortColumnCommand

sorts a column

TabLeft

- -

displays the previous sheet tabs to the left

TabRight

- -

displays the next sheet tabs to the right

Update

UpdateCommand

saves the changes

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")

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);
   }
</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");
  }
</SCRIPT>

See Also

onCallBackStart | onCallBackStopped | Scripting Members

© 2002-2012 GrapeCity, Inc. All Rights Reserved.