Selecting the first row by default
Selecting the first row by default
Thanks for such a nice JS plugin. I am using DataTables in a page where on selecting the row, it displays the details of the selected row below the DataTable. This is working perfectly fine. However I have a requirement that when user comes to this page. The first row must be already selected and the details of the row must be visible. I already have a click event for row selection and I somehow wants to invoke that method when the page is loaded. Below is sample click event
[code]
$("#tbl-example tbody tr")
.live(
"click",
function(e) {
var originalScrollPosition = $(
".dataTables_scrollBody")
.scrollTop();
aPos = oTable.fnGetPosition(this);
if (fi_pageEdit) {
if (previousEditedRow == aPos) {
if (previousEditedRow != lastRowCancelled) {
return;
}
lastRowCancelled = null;
} else {
if (previousEditedRow != undefined) {
if (fi_isDirty) {
showDirtyDialogue();
return;
} else {
colChangedArray = [];
var oldRowData = oTable
.fnGetData(previousEditedRow);
revertCurrentRow(oldRowData[7]);
}
}
}
}
performClick(this);
$(".dataTables_scrollBody").scrollTop(
originalScrollPosition);
});
[/code]
[code]
$("#tbl-example tbody tr")
.live(
"click",
function(e) {
var originalScrollPosition = $(
".dataTables_scrollBody")
.scrollTop();
aPos = oTable.fnGetPosition(this);
if (fi_pageEdit) {
if (previousEditedRow == aPos) {
if (previousEditedRow != lastRowCancelled) {
return;
}
lastRowCancelled = null;
} else {
if (previousEditedRow != undefined) {
if (fi_isDirty) {
showDirtyDialogue();
return;
} else {
colChangedArray = [];
var oldRowData = oTable
.fnGetData(previousEditedRow);
revertCurrentRow(oldRowData[7]);
}
}
}
}
performClick(this);
$(".dataTables_scrollBody").scrollTop(
originalScrollPosition);
});
[/code]
This discussion has been closed.