/**
- * @extends Roo.bootstrap.Table.AbstractSelectionModel
- * @class Roo.bootstrap.Table.RowSelectionModel
- * The default SelectionModel used by {@link Roo.bootstrap.Table}.
- * It supports multiple selections and keyboard selection/navigation.
- * @constructor
- * @param {Object} config
+ * @deprecated
+ *
+ *
*/
Roo.bootstrap.Table.RowSelectionModel = function(config){
});
Roo.bootstrap.Table.RowSelectionModel.superclass.constructor.call(this);
this.locked = false;
-};
+ };
Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSelectionModel, {
/**
singleSelect : false,
// private
- initEvents : function(){
-
- if(!this.grid.enableDragDrop && !this.grid.enableDrag){
- this.grid.on("mousedown", this.handleMouseDown, this);
- }else{ // allow click to work like normal
- this.grid.on("rowclick", this.handleDragableRowClick, this);
- }
+ initEvents : function()
+ {
+ //if(!this.grid.enableDragDrop && !this.grid.enableDrag){
+ // this.growclickrid.on("mousedown", this.handleMouseDown, this);
+ //}else{ // allow click to work like normal
+ // this.grid.on("rowclick", this.handleDragableRowClick, this);
+ //}
+ //this.grid.on("rowdblclick", this.handleMouseDBClick, this);
+ this.grid.on("rowclick", this.handleMouseDown, this);
+
this.rowNav = new Roo.KeyNav(this.grid.getGridEl(), {
"up" : function(e){
if(!e.shiftKey){
},
scope: this
});
-
+ this.grid.store.on('load', function(){
+ this.selections.clear();
+ },this);
+ /*
var view = this.grid.view;
view.on("refresh", this.onRefresh, this);
view.on("rowupdated", this.onRowUpdated, this);
view.on("rowremoved", this.onRemove, this);
+ */
},
// private
- onRefresh : function(){
- var ds = this.grid.dataSource, i, v = this.grid.view;
+ onRefresh : function()
+ {
+ var ds = this.grid.store, i, v = this.grid.view;
var s = this.selections;
s.each(function(r){
if((i = ds.indexOfId(r.id)) != -1){
* @param {Array} records The records to select
* @param {Boolean} keepExisting (optional) True to keep existing selections
*/
- selectRecords : function(records, keepExisting){
+ selectRecords : function(records, keepExisting)
+ {
if(!keepExisting){
this.clearSelections();
}
- var ds = this.grid.dataSource;
+ var ds = this.grid.store;
for(var i = 0, len = records.length; i < len; i++){
this.selectRow(ds.indexOf(records[i]), true);
}
* @param {Boolean} keepExisting (optional) True to keep existing selections
*/
selectLastRow : function(keepExisting){
- this.selectRow(this.grid.dataSource.getCount() - 1, keepExisting);
+ //this.selectRow(this.grid.dataSource.getCount() - 1, keepExisting);
+ this.selectRow(this.grid.store.getCount() - 1, keepExisting);
},
/**
* Selects the row immediately following the last selected row.
* @param {Boolean} keepExisting (optional) True to keep existing selections
*/
- selectNext : function(keepExisting){
- if(this.last !== false && (this.last+1) < this.grid.dataSource.getCount()){
+ selectNext : function(keepExisting)
+ {
+ if(this.last !== false && (this.last+1) < this.grid.store.getCount()){
this.selectRow(this.last+1, keepExisting);
this.grid.getView().focusRow(this.last);
}
/**
* Clears all selections.
*/
- clearSelections : function(fast){
- if(this.locked) return;
+ clearSelections : function(fast)
+ {
+ if(this.locked) {
+ return;
+ }
if(fast !== true){
- var ds = this.grid.dataSource;
+ var ds = this.grid.store;
var s = this.selections;
s.each(function(r){
this.deselectRow(ds.indexOfId(r.id));
* Selects all rows.
*/
selectAll : function(){
- if(this.locked) return;
+ if(this.locked) {
+ return;
+ }
this.selections.clear();
- for(var i = 0, len = this.grid.dataSource.getCount(); i < len; i++){
+ for(var i = 0, len = this.grid.store.getCount(); i < len; i++){
this.selectRow(i, true);
}
},
* @return {Boolean}
*/
isSelected : function(index){
- var r = typeof index == "number" ? this.grid.dataSource.getAt(index) : index;
+ var r = typeof index == "number" ? this.grid.store.getAt(index) : index;
return (r && this.selections.key(r.id) ? true : false);
},
return (this.selections.key(id) ? true : false);
},
+
+ // private
+ handleMouseDBClick : function(e, t){
+
+ },
// private
- handleMouseDown : function(e, t){
- var view = this.grid.getView(), rowIndex;
- if(this.isLocked() || (rowIndex = view.findRowIndex(t)) === false){
+ handleMouseDown : function(e, t)
+ {
+ var rowIndex = this.grid.headerShow ? t.dom.rowIndex - 1 : t.dom.rowIndex ; // first row is header???
+ if(this.isLocked() || rowIndex < 0 ){
return;
};
if(e.shiftKey && this.last !== false){
var last = this.last;
this.selectRange(last, rowIndex, e.ctrlKey);
this.last = last; // reset the last
- view.focusRow(rowIndex);
+ t.focus();
+
}else{
var isSelected = this.isSelected(rowIndex);
- if(e.button !== 0 && isSelected){
- view.focusRow(rowIndex);
- }else if(e.ctrlKey && isSelected){
+ //Roo.log("select row:" + rowIndex);
+ if(isSelected){
this.deselectRow(rowIndex);
- }else if(!isSelected){
- this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
- view.focusRow(rowIndex);
+ } else {
+ this.selectRow(rowIndex, true);
}
+
+ /*
+ if(e.button !== 0 && isSelected){
+ alert('rowIndex 2: ' + rowIndex);
+ view.focusRow(rowIndex);
+ }else if(e.ctrlKey && isSelected){
+ this.deselectRow(rowIndex);
+ }else if(!isSelected){
+ this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
+ view.focusRow(rowIndex);
+ }
+ */
}
this.fireEvent("afterselectionchange", this);
},
* @param {Boolean} keepExisting (optional) True to retain existing selections
*/
selectRange : function(startRow, endRow, keepExisting){
- if(this.locked) return;
+ if(this.locked) {
+ return;
+ }
if(!keepExisting){
this.clearSelections();
}
* @param {Number} endRow The index of the last row in the range
*/
deselectRange : function(startRow, endRow, preventViewNotify){
- if(this.locked) return;
+ if(this.locked) {
+ return;
+ }
for(var i = startRow; i <= endRow; i++){
this.deselectRow(i, preventViewNotify);
}
* @param {Number} row The index of the row to select
* @param {Boolean} keepExisting (optional) True to keep existing selections
*/
- selectRow : function(index, keepExisting, preventViewNotify){
- if(this.locked || (index < 0 || index >= this.grid.dataSource.getCount())) return;
+ selectRow : function(index, keepExisting, preventViewNotify)
+ {
+ if(this.locked || (index < 0 || index > this.grid.store.getCount())) {
+ return;
+ }
if(this.fireEvent("beforerowselect", this, index, keepExisting) !== false){
if(!keepExisting || this.singleSelect){
this.clearSelections();
}
- var r = this.grid.dataSource.getAt(index);
+
+ var r = this.grid.store.getAt(index);
+ //console.log('selectRow - record id :' + r.id);
+
this.selections.add(r);
this.last = this.lastActive = index;
if(!preventViewNotify){
- this.grid.getView().onRowSelect(index);
+ var proxy = new Roo.Element(
+ this.grid.getRowDom(index)
+ );
+ proxy.addClass('bg-info info');
}
this.fireEvent("rowselect", this, index, r);
this.fireEvent("selectionchange", this);
* Deselects a row.
* @param {Number} row The index of the row to deselect
*/
- deselectRow : function(index, preventViewNotify){
- if(this.locked) return;
+ deselectRow : function(index, preventViewNotify)
+ {
+ if(this.locked) {
+ return;
+ }
if(this.last == index){
this.last = false;
}
if(this.lastActive == index){
this.lastActive = false;
}
- var r = this.grid.dataSource.getAt(index);
+
+ var r = this.grid.store.getAt(index);
+ if (!r) {
+ return;
+ }
+
this.selections.remove(r);
+ //.console.log('deselectRow - record id :' + r.id);
if(!preventViewNotify){
- this.grid.getView().onRowDeselect(index);
+
+ var proxy = new Roo.Element(
+ this.grid.getRowDom(index)
+ );
+ proxy.removeClass('bg-info info');
}
this.fireEvent("rowdeselect", this, index);
this.fireEvent("selectionchange", this);
g.startEditing(newCell[0], newCell[1]);
}
}
-});
\ No newline at end of file
+});