Closeing a non-visible row
Closeing a non-visible row
Okay, so I have a table with a click event on the rows to open them, as per one of the examples (but on the tr, not an image within). I also close any others that are already open.
Now my problem comes when data is filtered, how can I select an already opened row that's not visible anymore, to close it?
When I have a selected row, and I filter it out of the visible set, click on another row, that opens up, but it can't close the now invisible row. Thus, if the person then erases the filter field's content, and all rows are shown again, multiple will be open.
The below is my best thoughts for how to accomplish this, but it doesn't work, I'm figuring since the row is not visible when I tell it to close.
Here are my two bound events, in regards to the filter of the table. This is all on one screen, without a StateSave set, so no need for a .live() call.
[code]
var selected;
var example = $('#example').DataTable(); // The init has been skipped here, because I don't think it is particularly relevant.
// ...
$('#example_filter').keydown(function(){
selected = $('#example .details').parents('tr').prev('tr'); // 'details' is the third parameter used in the fnOpen call.
})
$('#example_filter').keyup(function(){
if (('#example').find(selected).size == 0) {
example.fnClose(selected[0]);
}
});
[/code]
Now my problem comes when data is filtered, how can I select an already opened row that's not visible anymore, to close it?
When I have a selected row, and I filter it out of the visible set, click on another row, that opens up, but it can't close the now invisible row. Thus, if the person then erases the filter field's content, and all rows are shown again, multiple will be open.
The below is my best thoughts for how to accomplish this, but it doesn't work, I'm figuring since the row is not visible when I tell it to close.
Here are my two bound events, in regards to the filter of the table. This is all on one screen, without a StateSave set, so no need for a .live() call.
[code]
var selected;
var example = $('#example').DataTable(); // The init has been skipped here, because I don't think it is particularly relevant.
// ...
$('#example_filter').keydown(function(){
selected = $('#example .details').parents('tr').prev('tr'); // 'details' is the third parameter used in the fnOpen call.
})
$('#example_filter').keyup(function(){
if (('#example').find(selected).size == 0) {
example.fnClose(selected[0]);
}
});
[/code]
This discussion has been closed.
Replies
etc are only going to find rows in the DOM. Use the `$` API method or fnGetNodes to operate on all nodes. For example:
[code]
example.$('.selected')
[/code]
Allan