getRecord :
YAHOO.widget.Record getRecord ( row )
For the given identifier, returns the associated Record instance.传入RecordSet position Index或者Recod Id 返回 该行的实例
updateCell:void updateCell ( oRecord , oColumn , oData , skipRender )
For the given row and column, updates the Record with the given data. If the cell is on current page, the corresponding DOM elements are also updated.
- Parameters:
oRecord < YAHOO.widget.Record>
Record instance.oColumn < YAHOO.widget.Column | String | Number>
A Column key, or a ColumnSet key index.oData < Object>
New data value for the cell.skipRender < Boolean>
Skips render step. Editors that update multiple cells in ScrollingDataTable should render only on the last call to updateCell().- 更新cell,传入行实例,列实例,cell值。如果是scrolling table需特殊处理
getColumn:
YAHOO.widget.Column getColumn ( column )
For the given identifier, returns the associated Column instance. Note: For getting Columns by Column ID string, please use the method getColumnById().
- Parameters:
column < HTMLElement | String | Number>
TH/TD element (or child of a TH/TD element), a Column key, or a ColumnSet key index.
- Returns:
YAHOO.widget.Column
- Column instance.
- 传入index,id或者key获取列的实例
其他行操作相关的用法见:yui-datatable常用知识总结
var recordsSet = myTable.getRecordSet(); var records = recordsSet.getRecords(); var columnObject = myTable.getColumn("RN"); for(var s=0; s<records.length; s++){ var t = s+1; var id = records[s].getId(); var recordInstance = myTable.getRecord(id); myTable.updateCell(recordInstance,columnObject,t); }
本例中是新添加行和删除行时重新生成行号:
function addRowsForYUIDataTable(rowData){ var myTable = Map.realYUIDataTable; var recordsSet = myTable.getRecordSet(); var records = recordsSet.getRecords(); var vehicleIdSet = new Array(); for(var i=0; i<records.length; i++){ var oData = records[i]._oData; vehicleIdSet[i] = oData.VEHICLEID; } for(var i=0; i<rowData.length; i++){ var vechileId = rowData[i].VEHICLEID; for(var j=0; j<vehicleIdSet.length; j++){ if(vechileId == vehicleIdSet[j]){ return false; } } myTable.addRow(rowData[i],0); } var columnObject = myTable.getColumn("RN"); for(var s=0; s<records.length; s++){ var t = s+1; var id = records[s].getId(); var recordInstance = myTable.getRecord(id); myTable.updateCell(recordInstance,columnObject,t); } } //表格删除行 function deleteRowsForYUIDataTable(rowData){ var myTable = Map.realYUIDataTable; var recordsSet = myTable.getRecordSet(); var records = recordsSet.getRecords(); for(var i=0; i<rowData.length; i++){ var vechileId = rowData[i].VEHICLEID; for(var j=0; j<records.length; j++){ var oData = records[j]._oData; if(vechileId == oData.VEHICLEID){ myTable.deleteRow(records[j].getId()); } } } var columnObject = myTable.getColumn("RN"); for(var s=0; s<records.length; s++){ var t = s+1; var id = records[s].getId(); var recordInstance = myTable.getRecord(id); myTable.updateCell(recordInstance,columnObject,t); } }
排序行号:使用sortColumn方法:
sortColumn:
void sortColumn ( oColumn , sDir )
Sorts given Column. If "dynamicData" is true, current selections are purged before a request is sent to the DataSource for data for the new state (using the request returned by "generateRequest()").
- Parameters:
oColumn < YAHOO.widget.Column>
Column instance.sDir < String>
(Optional) YAHOO.widget.DataTable.CLASS_ASC or YAHOO.widget.DataTable.CLASS_DESC
- 给定列实例和排序方式排序给定列
yui datatable动态修改行号,布布扣,bubuko.com
原文:http://www.cnblogs.com/wishyouhappy/p/3736224.html