add select all checkbox to tree view
This commit is contained in:
parent
a31571095e
commit
ccc5d09fa1
1 changed files with 58 additions and 11 deletions
|
|
@ -1012,6 +1012,16 @@ WebGUI.Admin.LocationBar.prototype.swapForwardToBack
|
||||||
|
|
||||||
WebGUI.Admin.Tree
|
WebGUI.Admin.Tree
|
||||||
= function(){
|
= function(){
|
||||||
|
var selectAllCheck = document.createElement( 'input' );
|
||||||
|
selectAllCheck.id = 'treeSelectAllCheckbox';
|
||||||
|
selectAllCheck.type = "checkbox";
|
||||||
|
// Add the event handler in onDataTableInitializeRows because innerHTML won't
|
||||||
|
// save event handlers
|
||||||
|
|
||||||
|
// Create a span so we can get innerHTML to put in DataTable's label
|
||||||
|
var selectAllSpan = document.createElement( 'span' );
|
||||||
|
selectAllSpan.appendChild( selectAllCheck );
|
||||||
|
|
||||||
this.moreMenusDisplayed = {};
|
this.moreMenusDisplayed = {};
|
||||||
this.crumbMoreMenu = null;
|
this.crumbMoreMenu = null;
|
||||||
this.defaultSortBy = {
|
this.defaultSortBy = {
|
||||||
|
|
@ -1058,7 +1068,7 @@ WebGUI.Admin.Tree
|
||||||
|
|
||||||
this.columnDefs
|
this.columnDefs
|
||||||
= [
|
= [
|
||||||
{ key: 'assetId', label: 'Select All Button', formatter: this.formatAssetIdCheckbox },
|
{ key: 'assetId', label: selectAllSpan.innerHTML, formatter: this.formatAssetIdCheckbox },
|
||||||
{ key: 'lineage', label: window.admin.i18n.get('Asset','rank'), sortable: true, formatter: this.formatRank },
|
{ key: 'lineage', label: window.admin.i18n.get('Asset','rank'), sortable: true, formatter: this.formatRank },
|
||||||
{ key: 'actions', label: "", formatter: this.formatActions },
|
{ key: 'actions', label: "", formatter: this.formatActions },
|
||||||
{ key: 'title', label: window.admin.i18n.get('Asset', '99'), formatter: this.formatTitle, sortable: true },
|
{ key: 'title', label: window.admin.i18n.get('Asset', '99'), formatter: this.formatTitle, sortable: true },
|
||||||
|
|
@ -1181,6 +1191,21 @@ WebGUI.Admin.Tree.prototype.findRow
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* findCheckbox( row )
|
||||||
|
* Find the checkbox in the row for the assetId field
|
||||||
|
*/
|
||||||
|
WebGUI.Admin.Tree.prototype.findCheckbox
|
||||||
|
= function ( row ) {
|
||||||
|
var inputs = row.getElementsByTagName( "input" );
|
||||||
|
for ( var i = 0; i < inputs.length; i++ ) {
|
||||||
|
if ( inputs[i].name == "assetId" ) {
|
||||||
|
return inputs[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* formatActions ( )
|
* formatActions ( )
|
||||||
* Format the Edit and More links for the row
|
* Format the Edit and More links for the row
|
||||||
|
|
@ -1345,6 +1370,26 @@ WebGUI.Admin.Tree.prototype.goto
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* toggleAllRows( )
|
||||||
|
* Toggle all the rows in the data table to the state of the Select All
|
||||||
|
* Checkbox
|
||||||
|
*/
|
||||||
|
WebGUI.Admin.Tree.prototype.toggleAllRows
|
||||||
|
= function ( ) {
|
||||||
|
var state = document.getElementById( 'treeSelectAllCheckbox' ).checked ? true : false;
|
||||||
|
var row = this.dataTable.getFirstTrEl();
|
||||||
|
while ( row ) {
|
||||||
|
if ( state ) {
|
||||||
|
this.selectRow( row );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.deselectRow( row );
|
||||||
|
}
|
||||||
|
row = this.dataTable.getNextTrEl( row );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* onDataReturnInitializeTable ( sRequest, oResponse, oPayload )
|
* onDataReturnInitializeTable ( sRequest, oResponse, oPayload )
|
||||||
* Initialize the table with a new response from the server
|
* Initialize the table with a new response from the server
|
||||||
|
|
@ -1353,6 +1398,8 @@ WebGUI.Admin.Tree.prototype.onDataReturnInitializeTable
|
||||||
= function ( sRequest, oResponse, oPayload ) {
|
= function ( sRequest, oResponse, oPayload ) {
|
||||||
this.dataTable.onDataReturnInitializeTable.call( this.dataTable, sRequest, oResponse, oPayload );
|
this.dataTable.onDataReturnInitializeTable.call( this.dataTable, sRequest, oResponse, oPayload );
|
||||||
|
|
||||||
|
YAHOO.util.Event.addListener( 'treeSelectAllCheckbox', "click", this.toggleAllRows, this, true );
|
||||||
|
|
||||||
// Rebuild the crumbtrail
|
// Rebuild the crumbtrail
|
||||||
var crumb = oResponse.meta.crumbtrail;
|
var crumb = oResponse.meta.crumbtrail;
|
||||||
var elCrumb = document.getElementById( "treeCrumbtrail" );
|
var elCrumb = document.getElementById( "treeCrumbtrail" );
|
||||||
|
|
@ -1400,18 +1447,18 @@ WebGUI.Admin.Tree.prototype.removeHighlightFromRow
|
||||||
*/
|
*/
|
||||||
WebGUI.Admin.Tree.prototype.selectRow
|
WebGUI.Admin.Tree.prototype.selectRow
|
||||||
= function ( child ) {
|
= function ( child ) {
|
||||||
// First find the row
|
|
||||||
var node = this.findRow( child );
|
|
||||||
this.addHighlightToRow( child );
|
this.addHighlightToRow( child );
|
||||||
|
this.findCheckbox( this.findRow( child ) ).checked = true;
|
||||||
|
};
|
||||||
|
|
||||||
// Now find the assetId checkbox in the first element
|
/**
|
||||||
var inputs = node.getElementsByTagName( "input" );
|
* deselectRow( child )
|
||||||
for ( var i = 0; i < inputs.length; i++ ) {
|
* Uncheck the checkbox and toggle the highlight
|
||||||
if ( inputs[i].name == "assetId" ) {
|
*/
|
||||||
inputs[i].checked = true;
|
WebGUI.Admin.Tree.prototype.deselectRow
|
||||||
break;
|
= function ( child ) {
|
||||||
}
|
this.removeHighlightFromRow( child );
|
||||||
}
|
this.findCheckbox( this.findRow( child ) ).checked = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue