leostiw leostiw - 2 months ago 9x
Ajax Question

Rowunselect without ctrl+click

Is there a possibility to unselect a row without to hold the control key,only by clickin on it? By that I mean, if you click on an already selected row, it should unselect, without having to hold the control key.


I have tested with Primefaces 3.4.2: xhtml page:

<script type="text/javascript">
                function test(xhr, status, args){
                    if(args.unselecttest % 2 == 1){
<p:dataTable widgetVar="stest" selectionMode="single" selection="#{tabview.car}"
<p:ajax event="rowSelect" oncomplete="test(xhr, status, args);" />


private int count = 0;

    public Car getCar() {
        return car;

    public void setCar(Car car) {
        if (car.equals(this.car)) {
            RequestContext reqCtx = RequestContext.getCurrentInstance();
            reqCtx.addCallbackParam("unselecttest", count);
        } else {
            count = 0;
        this.car = car;