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:

Function Description
updateData(bool cancelEdit) Updates all client data of Aspose.Cells.GridWeb before posting it to the server. If the cancelEdit parameter is true, 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, it returns true.
submit(string arg, bool cancelEdit) Call this function to post back or submit data to the server. This function performs both tasks, which are updating data and validating user input. It can also fire a command event on the server side. Use the arg parameter to pass your command. For example, the SAVE command is used when 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 into any cell specified by 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 selections excluding the current active cell.
getCellsArray() 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 <script></script> 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 the C1 cell

todo:image_alt_text

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

ValidationErrorFunction invoked on validation error

todo:image_alt_text

Until 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 the server

todo:image_alt_text