2008年9月24日星期三

RICO notes

1, 设置Rico.TabbedPanel某个tab为选中状态。 tabs.openByIndex(); tabs.selectionSet.select($$('div.panelHeader'[2]));


2, 删除Rico.LiveGrid 中的一行。
<script type='text/javascript'>
var gridA;
Rico.loadModule('LiveGrid','LiveGridMenu','greenHdg.css');
Rico.onLoad( function() {
var buffer = new Rico.Buffer.Base($('licenseePayloadDG').tBodies[0]);
var grid_options = {
columnSpecs: [ {width:280},
{width:280},
{width:180},
{width:200}
]
};
gridA = new Rico.LiveGrid('licenseePayloadDG', buffer, grid_options);
});


function deleteCurrentRow(obj){
var cell = obj.parentNode;
gridA.selectCell(cell);
var row = gridA.SelectIdxStart.row; // SelectIdxStart.row 表示了当前选中的行的index。
var col = gridA.SelectIdxStart.column; // SelectIdxStart.column 表示了当前选中的列的index。
var cols = gridA.headerColCnt; // headerColCnt 表示了列的总数,是个常量。

gridA.selectRow(row); // selectRow(row) 高亮某行。row是行的索引。

// buffer 是Rico LiveGrid的数据模型对象。baseRows是数组格式的数据。baseRows.splice(row, count) 就把数据从数据模型中删除了。
gridA.buffer.baseRows.splice(row, 1);

// 删除数据后需要刷新页面才能看出效果。
gridA.refreshContents(0);
}


function removeCellzRow(row) {
for( var c=0; c < gridA.headerColCnt; c++ ) {
// LiveGrid的表格形式并不是由HTML table 表示的由<div> + css表现的。columns[]表示了所有的列。columns[c].cell(row)定位到了一个cell.
var cell=gridA.columns[c].cell(row);

// 选择一个单元格。
gridA.selectCell(cell);

// 清空一个单元格的内容。注意: 设置innerHTML=""只是把表现层的东西清空了。后台的数据模型gridA.buffer.baseRows并没有改变。
cell.innerHTML = "";
}
}
</script>

对应的HTML: <a href="#" onclick='javascript: {if(confirm("deleteRow?")) {deleteCurrentRow(this); }else {}}'>DelRow</a>




1 条评论:

  1. Rico.loadModule('LiveGrid','LiveGridMenu','greenHdg.css'); 这一句中的三个参数分别代表什么意思

    回复删除