!--www--CodeThatGrid - Selective export, search from url!--www/--!--all--code that works!!--all/--

CodeThatGrid - Selective export, search from url

Search from url: Search in grid for "Skip"

|

//GLOBAL VARS
var DATE_FORMAT = "dd.mm.yyyy", CURRENCY_FORMAT = "$", EMPTY_ROW = "",
DEFAULT_COLDEF = {
	title : "",
	titleClass : "",
	type : "String", //the default type
	width : 80,
	alignment : "",
	compareFunction : compare,
	isVisible : 1,
	isReadOnly : 0,
	useAutoIndex : 0,
	useAutoFilter : 0
};
//Example of use user-type (Discount) in CodeThatGrid
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;
};
//GRID DEFINITION
var gridDef = {
	useExportBar 	 : false,
	useMultiSort	 : true,
	useColTitle 	 : true,
	datatype 		 : 1,
	data : "0;Stiles James;01.01.2002;jstiles@necasting.com;270\n
	1;Alexander Jacklynn;12.05.2003;speedracer1979@iwon.com;1\n
	2;Martin Barney;01.01.2002;bmartin1@maine.rr.com;92\n
	3;Gelinas Patricia;18.07.2003;pattigelinas@hotmail.com;364\n
	4;Cooke Dee;02.05.2002;findDeeCooke@aol.com;74\n
	5;Greiner Andrew;08.01.2003;andy_greiner@hotmail.com;0\n
	6;Maillet Chad;01.01.2002;ChadRM@rccw.com;265\n
	7;Batson Alecia;01.01.2002;acbatson@yahoo.com;0\n
	8;Gato Timothy;01.01.2002;tgato2@maine.rr.com;60\n
	9;Wheeler Skip;01.01.2002;skipw47@aol.com;59",
	colDef : [
	{
		title : "ID",
		titleClass : "",
		type : "Number",
		width : 50,
		alignment : "center",
		compareFunction : compare,
		isVisible : true,
		useAutoIndex : true,
		useAutoFilter : false
	},
	{
		title : "Name",
		titleClass : "",
		type : "String",
		width : 150,
		alignment : "",
		compareFunction : compare,
		isVisible : true,
		useAutoIndex : true,
		useAutoFilter : false
	},
	{
		title : "Reg. date",
		titleClass : "",
		type : "Date",
		width : 100,
		alignment : "center",
		compareFunction : compare,
		isVisible : true,
		useAutoIndex : true,
		useAutoFilter : false
	},
	{
		title : "E-mail",
		titleClass : "",
		type : "Email1",
		width : 100,
		alignment : "center",
		compareFunction : compare,
		isVisible : true,
		useAutoIndex : false,
		useAutoFilter : false
	},
	{
		title : "Discount",
		titleClass : "",
		type : "Discount",
		width : 0,
		alignment : "right",
		compareFunction : compareDiscount,
		isVisible : true,
		useAutoIndex : true,
		useAutoFilter : false
	} ],
	tableStyle : {
		tableClass : {
			borderwidth : 0, bordercolor : "#bbbbbb", borderstyle : "solid"
		},
		bgcolor : "#ffffff",
		x : 10,
		y : 10,
		width : 467,
		height : 360,
		overflow : "visible"
	},
	rowStyle : {
		defaultClass : {
			fontfamily : "Verdana", fontsize : "11px", backgroundcolor : "#ffffee"
		},
		markClass : {
			fontfamily : "Verdana", fontsize : "11px", backgroundcolor : "#ffffcc",
			borderwidth : "1", borderstyle : "outset", bordercolor : "#ffffee"
		},
		dragClass : {
			cursor : "move", borderwidth : "0"
		},
		width : 20,
		height : 21
	},
	colStyle : {
		defaultClass : {
			fontfamily : "Verdana", fontsize : "12px", backgroundcolor : "#ffffee"
		},
		markClass : {
			fontfamily : "Verdana", fontsize : "12px", backgroundcolor : "#ffffcc",
			borderwidth : "1", borderstyle : "outset", bordercolor : "#ffffee"
		},
		dragClass : {
			cursor : "move", borderwidth : "0"
		},
		width : 100,
		height : 21
	},
	cellStyle : {
		defaultClass : {
			borderwidth : "0", borderstyle : "solid", bordercolor : "#cfcfcf",
			fontfamily : "Arial", fontsize : "12px", backgroundcolor : "#ffffff", color : "#000000"
		},
		markClass : {
			borderwidth : "0", borderstyle : "outset", bordercolor : "#ffffee",
			fontfamily : "Arial", fontsize : "12px", backgroundcolor : "#ffffcc", color : "#000000"
		},
		currClass : {
			borderwidth : "1", borderstyle : "solid", bordercolor : "#000000",
			fontfamily : "Arial", fontsize : "12px", backgroundcolor : "#ffffcc", color : "#000000"
		}
	},
	toolBar : {
		height : 29,
		bgcolor : "#ffffff",
		defaultClass : {
			borderwidth : 0, bordercolor : "#bbbbbb", borderstyle : "solid"
		},
		buttons : [
		{
			name : "sortasc",
			img_on : {
				src : "img/sortasc.gif", width : "16", height : "16"
			},
			img_off : {
				src : "img/sortasc_off.gif", width : "16", height : "16"
			},
			text : "Sort data in current column in ascending order"
		},
		{
			name : "sortdesc",
			img_on : {
				src : "img/sortdesc.gif", width : "16", height : "16"
			},
			img_off : {
				src : "img/sortdesc_off.gif", width : "16", height : "16"
			},
			text : "Sort data in current column in descending order"
		},
		{
			name : "multisortasc",
			img_on : {
				src : "img/multisortasc.gif", width : "16", height : "16"
			},
			img_off : {
				src : "img/multisortasc_off.gif", width : "16", height : "16"
			},
			text : "Keep current order and sort data in current column in ascending order"
		},
		{
			name : "multisortdesc",
			img_on : {
				src : "img/multisortdesc.gif", width : "16", height : "16"
			},
			img_off : {
				src : "img/multisortdesc_off.gif", width : "16", height : "16"
			},
			text : "Keep current order and sort data in current column in descending order"
		},
		{
			name : "resetsort",
			img_on : {
				src : "img/resetsort.gif", width : "16", height : "16"
			},
			img_off : {
				src : "img/resetsort_off.gif", width : "16", height : "16"
			},
			text : "Reset sort"
		},
		{ },
		{
			name : "formatbold",
			img_on : {
				src : "img/formatbold.gif", width : "16", height : "16"
			},
			img_off : {
				src : "img/formatbold_off.gif", width : "16", height : "16"
			},
			text : "Format bold"
		},
		{
			name : "formatitalic",
			img_on : {
				src : "img/formatitalic.gif", width : "16", height : "16"
			},
			img_off : {
				src : "img/formatitalic_off.gif", width : "16", height : "16"
			},
			text : "Format italic"
		},
		{
			name : "formatunderline",
			img_on : {
				src : "img/formatunderline.gif", width : "16", height : "16"
			},
			img_off : {
				src : "img/formatunderline_off.gif", width : "16", height : "16"
			},
			text : "Format underline"
		},
		{ },
		{
			name : "alignleft",
			img_on : {
				src : "img/alignleft.gif", width : "16", height : "16"
			},
			img_off : {
				src : "img/alignleft_off.gif", width : "16", height : "16"
			},
			text : "Align left"
		},
		{
			name : "aligncenter",
			img_on : {
				src : "img/aligncenter.gif", width : "16", height : "16"
			},
			img_off : {
				src : "img/aligncenter_off.gif", width : "16", height : "16"
			},
			text : "Align center"
		},
		{
			name : "alignright",
			img_on : {
				src : "img/alignright.gif", width : "16", height : "16"
			},
			img_off : {
				src : "img/alignright_off.gif", width : "16", height : "16"
			},
			text : "Align right"
		},
		{ },
		{
			name : "setsearch",
			img_on : {
				src : "img/setsearch.gif", width : "16", height : "16"
			},
			text : "Search in grid"
		},
		{
			name : "resetsearch",
			img_on : {
				src : "img/resetsearch.gif", width : "16", height : "16"
			},
			text : "Reset search. Show all records."
		},
		{
			name : "setamount",
			img_on : {
				src : "img/setamount.gif", width : "16", height : "16"
			},
			text : "Set count of records per page"
		} ]
	},
	statusBar : {
		height : 15,
		bgcolor : "#ffffff",
		defaultClass : {
			color : "#000000", fontfamily : "Verdana", fontsize : "11px"
		},
		messageClass : {
			color : "#0000ff", fontfamily : "Verdana", fontsize : "11px"
		},
		fieldText : "Field",
		valueText : "Value"
	},
	pageTurnBar : {
		defaultClass : {
			backgroundcolor : "#ffffff", fontsize : "11px", fontfamily : "Verdana,Arial"
		},
		activeClass : {
			backgroundcolor : "#D4D0C8", fontsize : "11px", fontfamily : "Verdana,Arial"
		},
		img_on : {
			src : "img/t_on.gif"
		}, img_off : {
			src : "img/t_off.gif"
		},
		text : "Page", width : 65, height : 14
	}
};