Checkbox Selection Grid

To make the grid rows selectable, you need to install the ezEditTable extension, enable the selectable property and configure the ezEditTable configuration object (ezEditTable_config). This demo shows how to :

Note: keyboard navigation and selection are disabled in this demo.

 Id Name Email Start Date Salary
 28716Employee name...employee@email.com2011-01-010.00
 28715Employee name...employee@email.com2011-01-010.00
 28714Employee name...employee@email.com2011-01-010.00
 28713zdemployee@email.com2011-01-010.00
 28712zdzdzdemployee@email.com2011-01-010.00
 28711Employee name...employee@email.com2011-01-010.00
 28710Employee name...333employee@email.com2011-01-010.00
 28709Employee name...employee@email.com2011-01-010.00
 28708Employee name...employee@email.com2011-01-010.00
 28707Employee name...employee@email.com2011-01-010.00
 28706Employee name...employee@email.com2011-01-010.00
 28705Employee name...employee@email.com2011-01-010.00
 28704Employee name...employee@email.com2011-01-010.00
 28703Employee name...employee@email.com2011-01-010.00
 28702Employee name...employee@email.com2011-01-010.00
 28701Employee name...employee@email.com2011-01-010.00
 28700Employee name...employee@email.com2011-01-010.00
 28699Employee name...employee@email.com2011-01-010.00
 28698Employee name...employee@email.com2011-01-010.00
 28697Employee name...employee@email.com2011-01-010.00
 28696Employee name...employee@email.com2011-01-010.00
 28695Employee name...employee@email.com2011-01-010.00
 28694Employee name...employee@email.com2011-01-010.00
 28693Employee name...employee@email.com2011-01-010.00
 28692Employee name...employee@email.com2011-01-010.00
 28691Employee name...employee@email.com2011-01-010.00
 28690Employee name...employee@email.com2011-01-010.00
 28689Employee name...employee@email.com2011-01-010.00
 28688Employee name...employee@email.com2011-01-010.00
 28687Employee name...employee@email.com2011-01-010.00
 28686Employee name...employee@email.com2011-01-010.00
 28685Employee name...employee@email.com2011-01-010.00
 28684Employee name...employee@email.com2011-01-010.00
 28683Employee name...employee@email.com2011-01-010.00
 28682Employee name...employee@email.com2011-01-010.00
 28681Employee name...employee@email.com2011-01-010.00
 28680Employee name...employee@email.com2011-01-010.00
 28679Employee name...employee@email.com2011-01-010.00
 28678Employee name...employee@email.com2011-01-010.00
 28677Employee name...employee@email.com2011-01-010.00
 28676Employee name...employee@email.com2011-01-010.00
 28675Employee name...employee@email.com2011-01-010.00
 28674Employee name...employee@email.com2011-01-010.00
 28673Employee name...employee@email.com2011-01-010.00
 28672Employee name...employee@email.com2011-01-010.00
 28671Employee name...employee@email.com2011-01-010.00
 28670Employee name...employee@email.com2011-01-010.00
 28669Employee name...employee@email.com2011-01-010.00
 28668Employee name...employee@email.com2011-01-010.00
 28667Employee name...employee@email.com2011-01-010.00
 28666Employee name...employee@email.com2011-01-010.00
 28665Employee name...employee@email.com2011-01-010.00
 28664Employee name...employee@email.com2011-01-010.00
 28663Employee name...employee@email.com2011-01-010.00
 28662Employee name...employee@email.com2011-01-010.00
 28661Employee name...employee@email.com2011-01-010.00
 28660Employee name...employee@email.com2011-01-010.00
 28659Employee name...employee@email.com2011-01-010.00
 28658Employee name...employee@email.com2011-01-010.00
 28657Employee name...employee@email.com2011-01-010.00
 28656Employee name...employee@email.com2011-01-010.00
 28655Employee name...employee@email.com2011-01-010.00
 28654Employee name...employee@email.com2011-01-010.00
 28653Employee name...employee@email.com2011-01-010.00
 28652Employee name...employee@email.com2011-01-010.00
 28651Employee name...employee@email.com2011-01-010.00
 28650Employee name...employee@email.com2011-01-010.00
 28649Employee name...employee@email.com2011-01-010.00
 28648Employee name...employee@email.com2011-01-010.00
 28647Employee name...employee@email.com2011-01-010.00
 28646Employee name...employee@email.com2011-01-010.00
 28645Employee name...employee@email.com2011-01-010.00
 28644Employee name...employee@email.com2011-01-010.00
 28643Employee name...employee@email.com2011-01-010.00
 28642Employee name...employee@email.com2011-01-010.00
 28641Employee name...employee@email.com2011-01-010.00
 28640Employee name...employee@email.com2011-01-010.00
 28639Employee name...employee@email.com2011-01-010.00
 28638Employee name...employee@email.com2011-01-010.00
 28637Employee name...employee@email.com2011-01-010.00
 28636Employee name...employee@email.com2011-01-010.00
 28635Employee name...employee@email.com2011-01-010.00
 28634Employee name...employee@email.com2011-01-010.00
 28633Employee name...employee@email.com2011-01-010.00
 28632Employee name...employee@email.com2011-01-010.00
 28631Employee name...employee@email.com2011-01-010.00
 28630Employee name...employee@email.com2011-01-010.00
 28629Employee name...employee@email.com2011-01-010.00
 28628Employee name...employee@email.com2011-01-010.00
 28627Employee name...employee@email.com2011-01-010.00
 28626Employee name...employee@email.com2011-01-010.00
 28625Employee name...employee@email.com2011-01-010.00
 28624Employee name...employee@email.com2011-01-010.00
 28623Employee name...employee@email.com2011-01-010.00
 28622Employee name...employee@email.com2011-01-010.00
 28621Employee name...employee@email.com2011-01-010.00
 28620Employee name...employee@email.com2011-01-010.00
 28619Employee name...employee@email.com2011-01-010.00
 28618Employee name...employee@email.com2011-01-010.00
 28617Employee name...employee@email.com2011-01-010.00
		var tfConfig = {
			public_methods: true,
			btn_reset: true,
			alternate_rows: true,
			loader: true,
			rows_counter: true,
			paging: false,
			col_0: 'none',
			col_width:['70px', '50px', '280px', '220px', '100px', '100px'],
			col_date_type: [null, null, null, null, 'ymd', null],
			sort_config: { sort_types: ['number','string','string','ymd','number'] },
			grid_layout: true, grid_width: '840px', grid_height: '300px',
			grid_enable_cols_resizer: false,
			mark_active_columns: true,
			
			//Checkbox header is referenced once filters are generated
			on_filters_loaded: function(o){
				var headersRow = o.headTbl.rows[o.GetHeadersRowIndex()];
				var c = headersRow.cells[0];
				var ezConfig = o.fObj.ezEditTable_config;
				//header checkbox is referenced on ezEditTable configuration object o.ezEditTable.checkBoxAll
				ezConfig.checkBoxAll = tf_Tag(c, 'input')[0];
				//header checkbox always unselected at start
				ezConfig.checkBoxAll.checked = false;
				//Click event is attached to header checkbox, note o.fObj = TF configuration object
				tf_AddEvent(ezConfig.checkBoxAll, 'click', function(e){ o.fObj.toggleAll(o); });
			},
			
			selectable: true,
			editable: false,
			ezEditTable_config: {
				key_navigation: false,
				key_selection: false,
				selection_model: 'multiple',
				default_selection: 'row',
				selected_row_css: 'ezSlcRow',
				
				on_after_selected_row: function(o, row){
					var c = row.cells[0];
					var checkBox = o.Tag(c, 'input')[0];
					if(checkBox) checkBox.checked = true;
				},
				on_after_deselected_row: function(o, row){
					var c = row.cells[0];
					var checkBox = o.Tag(c, 'input')[0];
					if(checkBox) checkBox.checked = false;
					o.config.checkBoxAll.checked = false;
				}
			},
			
			/* Sky Blue theme */  
			themes: {   
				name:['SkyBlueTheme'],   
				src:['TableFilter/TF_Themes/SkyBlue/TF_SkyBlue.css'],   
				description:['SkyBlue stylesheet']
			},
			
			//Custom select all function used by header checkbox
			toggleAll: function(tf){ //tf = parent object: TF
				var o = tf.ezEditTable; //ezEditTable object referenced inside TF object
				if(o.config.checkBoxAll.checked == false){
					o.Selection.ClearSelections();
				} else {
					for(var i=o.startRow; i<o.GetRowsNb(); i++){
						//If table filtered, only valid rows are selected
						if(tf.GetValidRowsIndex()==null || tf.GetValidRowsIndex().indexOf(i) != -1)
							o.Selection.SelectRowByIndex(i);
					}
				}
			}
		};
		

E.n.j.o.y.  ads-free content!