3.2.0

text wrap issue when editing cell data

Alex;

In the move from 2.5.1 to the latest version I have lost the text wrap when you edit a cell. In the older code when you doubled clicked on a sell with a large amount of data, the resulting text box would wrap the text. In the new code the text is displayed on a single line. How can I wrap the text in the edit text box? Also my tab key does not move from cell to cell any more any ideas?


var HeaderText = [[Headings]];
var DataFields = [[DataFields]];
var CellText = [
[[Data]]
];

//var obj = new AW.UI.Grid;
var obj = new AW.Grid.Extended();
obj.setId("myGrid"); // necessary for CSS rules
obj.setHeaderText(HeaderText);
obj.setCellText(CellText);

// set number of columns/rows
obj.setRowCount(CellText.length-1);
obj.setColumnCount(HeaderText.length+1);
obj.setFixedLeft(5);
// enable row selectors
obj.setSelectorVisible(true);
obj.setSelectorText(function(i){return this.getRowPosition(i)+1});
obj.setSelectorWidth(25);

obj.setVirtualMode(true); // disable virtual mode
obj.getRowTemplate().setClass("text", "wrap"); // multiline text
obj.setRowHeight(50);

// code added 14-nov-2007 - rpnoble - trun off backspace keystroke bypass
obj.onCellEditStarting = function(text, column, row){BSBypass=false;};

//code added 29-Oct-2007 - rp noble - allert when cell edit is finished
obj.onCellEditEnded = function(text, col, row){
obj.getCellTemplate(0,row).setStyle("background-color","#FA8282");
obj.getCellTemplate(col,row).setStyle("background-color","#FA8282");
Changes=true;
BSBypass=true;
// alert("Edit ended - text: " + text + ", col: " + col + ", row: " + row);
}
//end of code added 29-Oct-2007 - rp noble - allert when cell edit is finished

if (window.parent.Level>=3)
{
obj.setCellEditable(true);
}

obj.setController("myTabKeys", {
onKeyTab: "selectNextCell",
onKeyShiftTab: "selectPreviousCell"
});

// DISABLE SORTING - This simple example will not work if sorted
// obj.onHeaderClicked = function(event,index){return 'disabled'};

// obj.setSelectionMode("single-row");

var colSizes = new Array(HeaderText.length) // array for colwidths
for (h=0;h<HeaderText.length;h++){ // intialize with header widths
colSizes[h]= HeaderText[h].length;
}
//get data function sets the col width for the
//data column if it is greater than the stored width

function getData(col, row){
var chars = CellText[row][col].length;
if ( chars > colSizes[col]) {
if (chars<70) { //70 char max to stop really wide cols.
if (chars<40){ chars=40; }
colSizes[col] = chars;
} else {
colSizes[col] = 70;
}
}
}

// write grid html to the page
document.write(obj);

obj.refresh();

// Autosizes Columns
var ssheet = document.styleSheets[document.styleSheets.length-1];
// cell text (function) for all cells
obj.setCellText( function(col, row){return CellText[row][col];getData(col,row)});

for( cs=0;cs<HeaderText.length;cs++) {

var tmpCS=colSizes[cs];
if (tmpCS<20) {tmpCS=20}

ssheet.addRule(".aw-column-"+cs, "width:"+((tmpCS*6)+20)+'px');
}


</script>

Richard Noble
October 21,
Alex;

Any Ideas. I'm at my wits end...
Richard Noble
October 28,

This topic is archived.

See also:


Back to support forum