Page 2 of 2
Re: DataTable: How to catch selection event with JavaScript?
Posted: 02 Nov 2011, 11:09
by dasago
Did you find out how it works with Version 3?
Re: DataTable: How to catch selection event with JavaScript?
Posted: 02 Nov 2011, 12:20
by Oleg
In 3.0 you can use
Code: Select all
<p:ajax event="rowSelect" .... onclick="handleCustomRowSelect(); return false;" />
with callback handler, but p:ajax doesn't generate an optimal code - p:ajax was designed to be used for ajax interactions. I would propose to use pe:javascript from PrimeFaces extensions project
http://code.google.com/p/primefaces-extensions/ (momentan you should build it from source, but i will be available in Maven central repo).
Code: Select all
<pe:javascript event="rowSelect" execute="handleCustomRowSelect();" />
Re: DataTable: How to catch selection event with JavaScript?
Posted: 02 Nov 2011, 17:04
by dasago
Hi Oleg,
thx for your fast reply.
I want to remove the ui-state-highlight class for selected rows.
With this code it works fine.. but i think there is still a better solution. Do you know one?
<p:ajax event="rowSelect" oncomplete="removeHighlight();" />
JS:
function removeHighlight(){
var elm = $("#formId\\:datatableId tr");
elm.removeClass('ui-state-highlight');
}
$(document).ready(function(){
removeHighlight();
});
I don't want to override the datatable.js of primefaces.
Re: DataTable: How to catch selection event with JavaScript?
Posted: 02 Nov 2011, 18:03
by Oleg
Hi,
Why do you remove it via JavaScript in oncomplete? Can you not overwrite .ui-state-highlight for datatable rows in CSS?
Re: DataTable: How to catch selection event with JavaScript?
Posted: 02 Nov 2011, 18:49
by dasago
The problem is, that i have even and odd rows. If i overwrite the css it doesn't work with even and odd...