Write GridWeb Client Side Script

Writing Client Side Scripts for Aspose.Cells.GridWeb

Basic Information

Aspose.Cells.GridWeb provides two properties created specifically to support client-side scripts:

  • OnSubmitClientFunction
  • OnValidationErrorClientFunction

Create JavaScript functions in an ASPX page and assign the names of these functions to the OnSubmitClientFunction and OnValidationErrorClientFunction properties.

Functions for Client-Side Scripting

Aspose.Cells.GridWeb also exposes functions especially for client-side scripting. These functions can be used within JavaScript functions to gain more control of Aspose.Cells.GridWeb. These client-side functions include the following:

Functions Description
updateData(bool cancelEdit) Updates all client data of Aspose.Cells.GridWeb before posting it to the server. If the cancelEdit parameter is true then GridWeb discards all user input.
validateAll() Used to check if there are any validation errors in the user input. If there is an error, the function returns false, otherwise true .
submit(string arg, bool cancelEdit) Call this function to postback or submit data to the server. This function performs both tasks that is updating data and validating user input. This function can also fire a command event at server side. Use the arg parameter to pass your command. For example: the SAVE command is used for clicking the Save button on the command bar of the GridWeb control and the CCMD:MYCOMMAND command fires a CustomCommand event.
setActiveCell(int row, int column) Used to activate a specific cell.
setCellValue(int row, int column, string value) Used to put a value to any cell specified using its row and column numbers.
getCellValue(int row, int column) Returns the value of any specified cell.
getActiveRow() Used in conjunction with the getActiveColumn() function to determine the position of an active cell.
getActiveColumn() Used in conjunction with the getActiveRow() function to determine the position of an active cell.
getSelectRange() Returns the last selected range.
setSelectRange() Selects the given range.
clearSelections() Clears all selection excluding current active cell.
getCellsArray() It is used with other related functions like getCellName(), getCellValueByCell(), getCellRow() and getCellColumn(). Please read this article for more information regarding the usage of this function: Read the values of the GridWeb cells on Client Side
To create a test application containing client-side scripts that work with Aspose.Cells.GridWeb, follow the steps below:
  1. Create JavaScript functions to be invoked by GridWeb. These functions will be added to the ASP.NET page’s tag.
  2. Assign the names of the functions to the OnSubmitClientFunction and OnValidationErrorClientFunction properties.

The output of the code example is shown below:

A validation added to C1 cell

todo:image_alt_text

Add an invalid value and click Save. A validation error occur and the ValidationErrorFunction is executed.

ValidationErrorFunction invoked on validation error

todo:image_alt_text

Untill you enter a valid value, no data is submitted to the server. Enter a valid value and click Save. The ConfirmFunction is executed.

ConfirmFunction invoked before submitting GridWeb data to server

todo:image_alt_text