Reputation: 71
I have a kendo spreadsheet which I have implemented validation for third column
<script>
var spreadsheet = $("#spreadsheet").kendoSpreadsheet({
toolbar: false,
sheets: [
{
rows: [
{
cells: [
{ value: "Id" },
{ value: "Name" },
{ value: "IsActive" }
]
}
]
},
{
name: "ListValues",
rows: [
{
cells: [
{
value: true
},
{
value: false
}
]
}
]
}
]
}).data("kendoSpreadsheet");
var range = spreadsheet.activeSheet().range("1:1");
range.enable(false);
var columnSens = spreadsheet.activeSheet().range("C2:C30");
columnSens.validation({
dataType: "list",
from: "ListValues!A$1:B$1",
allowNulls: true,
type: "reject",
titleTemplate: "Value Invalid",
messageTemplate: "Valid Values: 'true' or 'false'."
});
</script>
I want to know is there any way to perform validation by declaring an array like
var ListOfValues = [true,false];
and the calling the array in "from:" section, like :-
columnSens.validation({
dataType: "list",
from: "ListOfValues",
allowNulls: true,
type: "reject",
titleTemplate: "Value Invalid",
messageTemplate: "Valid Values: 'true' or 'false'."
});
Please guide me.
Upvotes: 1
Views: 933
Reputation: 676
To use an array for mapping to from property, simply serialize the array and replace '[' and ']' characters to '{' and '}' respectively.
var arr = ["name", "age", "whatever"];
the value for the from property would then be assigned like this:
{
from: JSON.stringify(arr).replace('[', '{').replace(']', '}')
}
Upvotes: 1