1 /* to be inherited by autogrid and similar */
2 if (!dojo._hasResource["openils.widget._GridHelperColumns"]) {
3 dojo._hasResource["openils.widget._GridHelperColumns"] = true;
5 dojo.provide("openils.widget._GridHelperColumns");
7 "openils.widget._GridHelperColumns", null, {
11 "hideLineNumber": false,
12 "lineNumberWidth": "1.5",
14 "getSelectedRows": function() {
17 dojo.query('[name=autogrid.selector]', this.domNode),
20 rows.push(input.getAttribute('row'));
26 "getFirstSelectedRow": function() {
27 return this.getSelectedRows()[0];
30 "getSelectedItems": function() {
33 dojo.forEach(this.getSelectedRows(), function(idx) { items.push(self.getItem(idx)); });
37 "selectRow": function(rowIdx) {
38 var inputs = dojo.query('[name=autogrid.selector]', this.domNode);
39 for(var i = 0; i < inputs.length; i++) {
40 if(inputs[i].getAttribute('row') == rowIdx) {
41 if(!inputs[i].disabled)
42 inputs[i].checked = true;
48 "deSelectRow": function(rowIdx) {
49 var inputs = dojo.query('[name=autogrid.selector]', this.domNode);
50 for(var i = 0; i < inputs.length; i++) {
51 if(inputs[i].getAttribute('row') == rowIdx) {
52 inputs[i].checked = false;
58 "toggleSelectAll": function() {
59 var selected = this.getSelectedRows();
60 for(var i = 0; i < this.rowCount; i++) {
68 "_formatRowSelectInput": function(rowIdx) {
69 if (rowIdx === null || rowIdx === undefined)
71 var s = "<input type='checkbox' name='autogrid.selector' row='"
73 if (this.disableSelectorForRow &&
74 this.disableSelectorForRow(rowIdx))
75 s += " disabled='disabled'";
79 // style the cells in the line number column
80 "onStyleRow": function(row) {
81 if (!this.hideLineNumber) {
82 var cellIdx = this.hideSelector ? 0 : 1;
84 this.views.views[0].getCellNode(row.index, cellIdx),
90 /* Don't allow sorting on the selector column */
91 "canSort": function(rowIdx) {
92 if (rowIdx == 1 && !this.hideSelector)
94 if (this.hideSelector && rowIdx == 1 && !this.hideLineNumber)
96 if (!this.hideSelector && rowIdx == 2 && !this.hideLineNumber)
101 "_startupGridHelperColumns": function() {
102 if (!this.hideLineNumber) {
103 this.structure[0].cells[0].unshift({
105 "get": function(rowIdx, item) {
106 if (item) return 1 + rowIdx;
108 "width": this.lineNumberWidth,
110 "nonSelectable": false
113 if (!this.hideSelector) {
114 this.structure[0].cells[0].unshift({
115 "field": "+selector",
116 "formatter": dojo.hitch(
117 this, function(rowIdx) {
118 return this._formatRowSelectInput(rowIdx);
121 "get": function(rowIdx, item) {
122 if (item) return rowIdx;
124 "width": this.selectorWidth,
126 "nonSelectable": true
129 this, "onHeaderCellClick", function(e) {
130 if (e.cell.index == 0)
131 this.toggleSelectAll();