All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.myfaces.custom.dojo.resource.src.widget.SortableTable.js Maven / Gradle / Ivy

/*
	Copyright (c) 2004-2006, The Dojo Foundation
	All Rights Reserved.

	Licensed under the Academic Free License version 2.1 or above OR the
	modified BSD license. For more information on Dojo licensing, see:

		http://dojotoolkit.org/community/licensing.shtml
*/

dojo.provide("dojo.widget.SortableTable");

dojo.deprecated("SortableTable will be removed in favor of FilteringTable.", "0.5");

dojo.require("dojo.lang.common");
dojo.require("dojo.date.format");
dojo.require("dojo.html.*");
dojo.require("dojo.html.selection");
dojo.require("dojo.html.util");
dojo.require("dojo.html.style");
dojo.require("dojo.event.*");
dojo.require("dojo.widget.*");
dojo.require("dojo.widget.HtmlWidget");

dojo.widget.defineWidget(
	"dojo.widget.SortableTable",
	dojo.widget.HtmlWidget,
	function(){
		this.data=[];
		this.selected=[];		//	always an array to handle multiple selections.
		this.columns=[];
	},
	{
		//	custom properties
		enableMultipleSelect: false,
		maximumNumberOfSelections: 0,	//	0 for unlimited, is the default.
		enableAlternateRows: false,
		minRows: 0,	//	0 means ignore.
		defaultDateFormat: "%D",
		sortIndex: 0,		//	index of the column sorted on, first is the default.
		sortDirection: 0,	//	0==asc, 1==desc
		valueField: "Id",	//	if a JSON structure is parsed and there is a field of this name,
							//	a value attribute will be added to the row (tr value="{Id}")

		headClass: "",
		tbodyClass: "",
		headerClass: "",
		headerSortUpClass: "selected",
		headerSortDownClass: "selected",
		rowClass: "",
		rowAlternateClass: "alt",
		rowSelectedClass: "selected",
		columnSelected: "sorted-column",

		isContainer: false,
		templatePath:null,
		templateCssPath:null,

		getTypeFromString:function(/* string */ s){
			//	summary
			//	Find the constructor that matches param s by searching through the entire object tree.
			var parts=s.split("."),i=0,obj=dj_global; 
			do{obj=obj[parts[i++]];}while(i=0){
				this.selected.splice(idx,1);
			}
		},
		getSelection:function(){
			//	summary
			//	return the array of currently selected objects (JSON format)
			return this.selected;	//	array
		},
		getValue:function(){
			//	summary
			//	return a comma-delimited list of selected valueFields.
			var a=[];
			for(var i=0;ib[field]) return 1;
						if (a[field]0) body.removeChild(body.childNodes[0]);
			for(var i=0; i0 && data.length0){
				thead.className=this.headClass;
			}

			//	disable selections
			dojo.html.disableSelection(this.domNode);

			//	parse the columns.
			this.parseColumns(thead);

			//	attach header handlers.
			var header="td";
			if(thead.getElementsByTagName(header).length==0) header="th";
			var headers=thead.getElementsByTagName(header);
			for(var i=0; i0) {
				tbody.className=this.tbodyClass;
			}

			this.parseDataFromTable(tbody);
			this.render(true);
		}
	}
);




© 2015 - 2024 Weber Informatics LLC | Privacy Policy