User Types
Let new user type is named UserType.
And, for example, at content.js file it's need to specify the following functions and variables:
var USERTYPE_FORMAT = "";
// Input : data : UserType,
// format : String
// Output:
// if data can't be formatted (for example null) return DEFAULT_RESULT;
function formatUserType(data, format)
{
return data;
}
// Input : data : ANY
// Output : if data can't be parsed return null;
function parseUserType(data)
{
return data; //:UserType
}
//function that compare op1, op2 : UserType
function compareUserType(op1, op2)
{
return result; //-1 (op1 < op2) | 0 (op1==op2) | 1 (op1 > op2)
};
|
Then you can use new user type at the column description.
Important - Please be careful writting type name!
Use upper case for all the letters at the format t ype string.
At the function names you should use the same letter case as for type name, which is used at the type field.
Example code:
var EMAIL1_FORMAT = " !";
function formatEmail1(data, format) {
return data + " " + format;
};
function parseEmail1(data) {
return "! " + data;
};
function compareEmail1(op1, op2) {
if (Undef(op1) && Undef(op2)) return 0;
else if (Undef(op1)) return 1;
else if (Undef(op2)) return - 1;
op1 = op1.toUpperCase();
op2 = op2.toUpperCase();
if (op1 > op2) return 1;
else if (op1 < op2) return - 1;
else return 0;
};
...
var gridDef =
{
...
colDef : ARRAY == [
{
title : "E-mail",
titleClass : "",
type : "Email1",
width : 0,
alignment : "center",
compareFunction : compareEmail1,
isVisible : true,
useAutoIndex : false,
useAutoFilter : false
},
...
|
Example - Email as new usertype
You can see an example and complete code here - Email as new usertype [popup]
Read more about CodeThatTable >>
|