javascript grid data dhtml grid javascript table MySQL server show data html page grid excell data presentation import export javascript row column cursor javascript table navigation grid cell dhtml table

PRODUCTS

JavaScript Projects

PHP Projects

Javascript Tools

Website Templates

SUPPORT

Standard vs PRO

FAQ

Forum

Contacts

Site Map

CODETHAT

Sales & Prices

Downloads

Users Testimonials

Affiliate registration

Our Customers

STUDIO   GRID   TABLE   MENU   TREE   XPBAR   HINT   EDITOR   TAB   FORM   CALENDAR   SCROLLER   SHOPPINGCART   TREEPHP   PACKER

User Manual

Introduction    Configure grid look    Grid general features

User types    Data from the DB / CSV / XML    Data Saving

Using XML    Grid reference    What's new?    Standard vs PRO

123Guide    Examples    Download

Order PRO Now    Themes

CODETHATGRID USER MANUAL

User Types

Let new user type is named UserType.

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.

You can also redifine all built-in type, just redefine the format* or parse* function for need type.

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:

//Add new type Discount
var DISCOUNT_FORMAT = "%";
function formatDiscount(data, format) {
	return data + " " + format;
};

function parseDiscount(data) {
	if (Undef(data)) return 0;
	data = parseFloat(data.replace(/[^0 - 9-\ + \.]/ig, ''));
	if (isNaN(data) || data < 0) data = 0;
	if (data > 100) data = 100;
	return new Number(data);
};

function compareDiscount(op1, op2) {
	if (Undef(op1) && Undef(op2)) return 0;
	else if (Undef(op1)) return 1;
	else if (Undef(op2)) return - 1;
	if (op1 > op2) return 1;
	else if (op1 < op2) return - 1;
	else return 0;
};

//Redefine type Number, it required only integer values >=0
function parseNumber(numVal) {
	if (Undef(numVal)) return 0;
	numVal = parseInt(numVal.replace(/[^0 - 9-\ + \.]/ig, ''));
	if (isNaN(numVal) || numVal < 0) return 0
	else return new Number(numVal);
};

var gridDef =
{
	...
	colDef : [
	{
		title : "Discount",
		titleClass : "",
		type : "Discount",
		width : 0,
		alignment : "center",
		compareFunction : compareDiscount,
		isVisible : true,
		isReadOnly : false,
		useAutoIndex : false,
		useAutoFilter : false
	},
	...

Example - Discount as new usertype

You can see an example and complete code here - Discount as new usertype [popup]

Read more about CodeThatGrid >>

[ Home ]  [ Forum ]  [ Contacts ]  [ Site Map ]  [ News ]  [ Links ]  [ Sales & Prices ]  [ Downloads ]

[ Go Top ]

© CodeThat.com, 2003-2008
Design by XTLabs, Inc.