[]
Sets a value of the cell at the specified row and column.
[JavaScript]
FpSpread1.SetValue(row,column,value,noEvent);
row
Integer, row index
column
Integer, column index
value
String, value
noEvent
Boolean, whether to trigger the onDataChanged event
None
This method sets the value of a cell at the specified row and column and triggers the onDataChanged event if specified. If noEvent is true, the method does not trigger an event; otherwise, the method triggers an onDataChanged event. This method does not cause a postback to occur.
This is a sample that contains the method.
On the server side on page load:
FpSpread1.Attributes.Add("onDataChanged", "ProfileSpread()")
On the client side, the script that contains the method would look like this:
<script type="text/javascript">
function ProfileSpread()
{
var szCell = document.all("FpSpread1");
if (szCell.ActiveCol == 0)
{
szCell.SetValue(0,1,"Scott",true);
alert("Test");
}
}
</script>
This example maps the onDataChanged event and uses the GetValue and SetValue methods to update the third cell with the sum of the first two cells any time the first or second cell is changed.
<script lang="javascript" type="text/javascript">
window.onload = function () {
var spread1 = document.getElementById("<%=FpSpread1.ClientID %>");
if (document.all) {
// IE
if (spread1.addEventListener) {
// IE9
spread1.addEventListener("DataChanged", dataChanged, false);
} else {
// Other versions of IE and IE9 quirks mode (no doctype set)
spread1.onDataChanged = dataChanged;
}
}
else {
// Firefox
spread1.addEventListener("DataChanged", dataChanged, false);
}
}
function dataChanged(event) {
var rc0=FpSpread1.GetValue(FpSpread1.ActiveRow, 0);
var rc1=FpSpread1.GetValue(FpSpread1.ActiveRow, 1);
var res = Number(rc0) + Number(rc1);
var sVal = ("" + res);
FpSpread1.SetValue(FpSpread1.ActiveRow, 2, sVal, true);
}
</script>