Prev | Current Page 289 | Next

Frank Zammetti

"Practical DWR 2 Projects"

It should now make sense why
checkboxNumber has to be global: there is no other way to get it to this function! Since its value
has to persist between invocations of this function, the variable has to exist outside the function.
CHAPTER 4 n INSTAMAIL: AN AJAX-BASED WEBMAIL CLIENT 153
After this comes a call to another very useful function from the DWRUtil object:
DWRUtil.addRows("inboxTBody", data,
[ getCheckbox, getFrom, getReceived, getSubject ], {
rowCreator:function(options) {
count++;
var row = document.createElement("tr");
if (altRow) {
row.rowClass = "msgListRow1";
row.className = "msgListRow1";
altRow = false;
} else {
row.rowClass = "msgListRow2";
row.className = "msgListRow2";
altRow = true;
}
row.msgType = data[options.rowIndex].msgType;
row.msgID = data[options.rowIndex].msgID;
return row;
},
cellCreator:function(options) {
var cell = document.createElement("td");
if (options.cellNum != 0) {
cell.onclick = gotoViewMessage;
cell.onmouseover = rowMouseOver;
cell.onmouseout = rowMouseOut;
}
return cell;
}
});
addRows() is another table modification function, this one focused on creating rows. Its
first argument is the ID of a element to populate.


Pages:
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301