Not select a row when I edit it
Not select a row when I edit it
jgcaudet
Posts: 82Questions: 7Answers: 0
Hi Allan
I want to make a multi-select of rows. But before select a row often I edit the record to review data.
I want that when I press the Edit button, TableTools not select the row, because I only want in this moment review data. Only when I press another element of my row then select the record.
Is possible ? How can I do? What code I must modify ?
I have an inline control button to Edit a record. In Tabletools, I have the parameter "sRowSelect": "multi".
To edit a record :
$('#example').on('click', 'a.editor_edit', function (e) {
editor.edit(..)
}
Can you help me?
Thanks.
I want to make a multi-select of rows. But before select a row often I edit the record to review data.
I want that when I press the Edit button, TableTools not select the row, because I only want in this moment review data. Only when I press another element of my row then select the record.
Is possible ? How can I do? What code I must modify ?
I have an inline control button to Edit a record. In Tabletools, I have the parameter "sRowSelect": "multi".
To edit a record :
$('#example').on('click', 'a.editor_edit', function (e) {
editor.edit(..)
}
Can you help me?
Thanks.
This discussion has been closed.
Replies
[code]
$('#example').on('click', 'a.editor_edit', function (e) {
e.stopPropagation();
editor.edit( ... );
} );
[/code]
That will stop the click event bubbling through to the row click handler that is placed on the table by TableTools.
Allan
$('#example').on('click', 'a.editor_edit', function (e) {
e.stopPropagation();
editor.edit(
$(this).parents('tr')[0],
'Record Data',
{ "label": "Update", "fn": function () { editor.submit() } }
);
} );
but the Editor window with the data of my record shows and hides automatically and come back to the menu from I execute my Datatables.
Thanks,
Allan
With this "return false" I get the row shows and wait for updating (not hides automatically and come back to the menu), but the row shows selected in datatables just behind the window editor .
Allan
I want that when I press the Edit button, TableTools not select the row, because I only want in this moment review data. Only when I press another element of my row then select the record.
However, I have a different solution - use the fnPreRowSelect callback of TableTools. THis is called before TableTools selected the row, so you can disallow the selection:
[code]
fnPreRowSelect: function ( e, rows ) {
return e.target.nodeName.toUpperCase() === 'A' ?
false : true;
}
[/code]
That will detect a click on an `a` tag and disallow the selection.
Regards,
Allan
fnPreRowSelect: function ( e, rows ) {
return e.target.nodeName.toUpperCase() === 'IMG' ? false : true;
}
and works. Thanks for all Allan. Thanks a lot.
"e is undefined" in this line
... e.target.nodeName.toUpperCase()
Why ?
[code]
var target = e.target || e.srcElement;
return target.nodeName.toUpperCase() === 'IMG' ? false : true;
[/code]
Allan
I try with
"oTableTools": {
"fnPreRowSelect": function ( e, rows ) {
if (!e) {
e = window.event ;
}
var target = e.target || e.srcElement;
return target.nodeName.toUpperCase() === 'IMG' ? false : true;
},
...}
and this
"oTableTools": {
"fnPreRowSelect": function ( e, rows ) {
var target = e.target || e.srcElement;
return target.nodeName.toUpperCase() === 'IMG' ? false : true;
},
...}
and always firefox debug says to me " e is undefined" in this line "var target = e.target || e.srcElement;"
Is there something I make wrong? Is PreRowSelect receiving the event ?
Thanks
Allan