[]
        
(Showing Draft Content)

Using Attributes

You can set attributes on the client side. There is an FpCellType attribute and an FpActiveSpread attribute. The FpCellType is an attribute on a table object (cell). FpActiveSpread is an attribute on a document object.

The following client functions are called by Spread when going in and out of edit mode on a table cell. You might find these functions useful when creating custom cells. You can use the FpCellType attribute to get to these functions. The methods are SetValue, GetValue, SetEditorValue, GetEditorValue, SetFocus, and IsValid.

Function

Description

SetValue

Called when setting the value to the renderer of the cell.

GetValue

Called when getting the value from the renderer to pass to the editor.

SetEditorValue

Called when setting the value from GetValue into the editor.

GetEditorValue

Called when getting the value from the editor to pass to the renderer.

SetFocus

Called when the editor is getting focus.

IsValid

Called when the cell is exiting edit mode and is used to determine if the value from GetEditorValue is valid.

The attribute of the cell type name is appended to the beginning of the function name. For example:

  • MyCellType_setValue

  • MyCellType_getValue

  • MyCellType_getEditorValue

  • MyCellType_setEditorValue

  • MyCellType_isValid

  • MyCellType_setFocus

The FpActiveSpread attribute can be used to query the Spread that is active, which is useful in hierarchical spreadsheets. The Spread ID on the client side may appear as follows:

<% FpSpread1.ClientID %>_r_i… where r is the ParentRowIndex and i is the relation index number to the child sheet. The ellipses mean to repeat _r_i for each level in the hierarchy.

The following example creates a custom cell and uses the FpCellType attribute:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim customButton As New customButton()
customButton.Text = "testing"
FpSpread1.Sheets(0).Cells(0, 0).CellType = customButton
End If
End Class
'add the following after your last end class

<Serializable()> Public Class customButton
Inherits FarPoint.Web.Spread.ButtonCellType
Public Sub New()
End Sub
Public Overrides Function PaintCell(ByVal id As String, ByVal parent As TableCell, ByVal style As FarPoint.Web.Spread.Appearance, ByVal margin As FarPoint.Web.Spread.Inset, ByVal val As Object, ByVal ul As Boolean) As System.Web.UI.Control
parent.Attributes.Add("FpCellType", "ztest")
Return MyBase.PaintCell(id, parent, style, margin, val, ul)
End Function
End Class

add the following to the aspx page

<SCRIPT language=javascript>
function ztest_getValue(rd){
return "";
}
</SCRIPT>