Minor refactoring in the navigation code. Implemented cell focusing on the record deletion with enabled pagination. The code profiled and checked for memory leaks.

This commit is contained in:
alekseybobkov 2014-11-27 21:55:37 -08:00
parent 839c686bb3
commit 1f420c88fd
3 changed files with 28 additions and 22 deletions

View File

@ -343,6 +343,22 @@
this.tableObj.focusCell(cell)
}
Navigation.prototype.focusCellInReplacedRow = function(rowIndex, cellIndex) {
if (rowIndex == 0)
this.focusCell('top', cellIndex)
else {
var focusRow = this.tableObj.findRowByIndex(rowIndex)
if (!focusRow)
focusRow = this.tableObj.findRowByIndex(rowIndex-1)
if (focusRow)
this.focusCell(focusRow, cellIndex)
else
this.focusCell('top', cellIndex)
}
}
// EVENT HANDLERS
// ============================

View File

@ -403,25 +403,15 @@
function onDeleteRecordDataTableSuccess(records, totalCount) {
self.buildDataTable(records, totalCount)
if (!paginationEnabled) {
if (currentRowIndex == 0)
self.navigation.focusCell('top', currentCellIndex)
else {
var focusRow = self.findRowByIndex(currentRowIndex)
if (!focusRow)
focusRow = self.findRowByIndex(currentRowIndex-1)
if (focusRow)
self.navigation.focusCell(focusRow, currentCellIndex)
else
self.navigation.focusCell('top', currentCellIndex)
}
if (!paginationEnabled)
self.navigation.focusCellInReplacedRow(currentRowIndex, currentCellIndex)
else {
if (currentPageIndex != self.navigation.pageIndex)
self.navigation.focusCell('bottom', currentCellIndex)
else
self.navigation.focusCellInReplacedRow(currentRowIndex, currentCellIndex)
}
// TODO - implement focusing for the pagination
// TODO - profile memory usage
self = null
}
)

View File

@ -61,7 +61,7 @@
'stickers' => 'Stickers string',
'__key' => 5
],
/* [
[
'name' => 'Country',
'type' => 'String',
'default' => 'Canada',
@ -324,11 +324,11 @@
'speakers' => 'Speakers string',
'stickers' => 'Stickers string',
'__key' => 27
]*/
]
];
?>
<div data-control="table" data-row-sorting="1" data-columns="<?= e(json_encode($columns)) ?>" data-data="<?= e(json_encode($data)) ?>"></div>
<!-- <div data-control="table" data-row-sorting="1" data-columns="<?= e(json_encode($columns)) ?>" data-data="<?= e(json_encode($data)) ?>"></div> -->
<!-- <div data-control="table" data-columns="<?= e(json_encode($columns)) ?>" data-data="<?= e(json_encode($data)) ?>" data-records-per-page="10"></div> -->
<div data-control="table" data-columns="<?= e(json_encode($columns)) ?>" data-data="<?= e(json_encode($data)) ?>" data-records-per-page="10"></div>