Fuction expected error on customValidationFunction

Hi,

I've tried customValidatoin at Web Grid. But I have encounter function expected error.

Here is my code:

Client side:

function customValidationFunction()

{

alert("test");

return true;

}

Server side:

sheet.Cells[row,col].Validation = new Validation();

sheet.Cells[row,col].Validation.ValidationType = ValidationType.CustomFunction;

sheet.Cells[row,col].Validation.ClientValidationFunction = "customValidationFunction()";

Looking for your reply.

Thanks,

John

Hi John,

Thanks for considering Aspose.

You may refer to our online demos and check the source code:

Aspose.Grid Demos .....and click Protection/Validation and check the source code here, how to set validation using custom functions

Thank you.

Hi,

Now I don't got error. But I need to know current Row and Col.

Can I get that info from source object? If so which method are available in source object?

Can you provide me the list of method that I can use from source object.

Otherwise Can I pass some parameters to customValidation?

Thank you,

John

Hi John,

Here is an example of setting the cell's value through the custom validation function for your need:
function myvalidation(source, value)
{
if (Number(value) > 10000)
return true;
else
{
var row, col;
var id = source.id.substring(GridWeb1.id.length + 1, source.id.length);
var row_col = id.split('#');
row = Number(row_col[1]);
col = Number(row_col[0]);
GridWeb1.setCellValue(row, col, "");
return false;
}
}
The source object is the cell. You can see that you must get the column and row number from the source object's id. And you can use the GridWeb object's setCellValue function to set the cell's value by passing the row and the column number and the value.
For client scripting details, please check the online wiki document.

Thank you.