homena / jmesa

Automatically exported from code.google.com/p/jmesa
0 stars 0 forks source link

RowEvent onclick, but get de column clicked #233

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi!! I've tryed get the column when I clicked on a row, but i can't get it.
After reading very much documentation, i can't solve the problem. I've made
a class extends from AbstractRowEvent:

@Override
public String execute(Object item, int rowcount) {
   System.out.println("***********" +
this.getRow().getColumn("checkbox").getProperty().toString());
   Object bean = ItemUtils.getItemValue(item, "news");
   Object nombreFichero = ItemUtils.getItemValue(bean, "fileName");
   return "javascript:document.getElementById('ruta').value='" +
nombreFichero.toString() + "';
javascript:document.getElementById('action').value='create';
javascript:document.pag_frm.submit();";
}

I have a column with checkbox, and if I click on any column of therow or
over the checkbox on the row, it work the same way. I want to differentiate
between make click on a checkbox or make click on the rest of columns. That
trace i write on the code (System.out.println("***********" +
this.getRow().getColumn("checkbox").getProperty().toString());) always show
me the first column (the checkbox in my case), so it isn't good for my mode
work. I can't to manage to differentiate the columns I click on.

I hope you can understand my case. My english isn't very good... sorry!!! :)

I tryed to use to the class ColumnEvent, but always I get an exception
because "jmesa:htmlRow" and "jmesa:htmlColumn" don't admit that class.
Where can I use that class to??

Thanks so much for you attention!!!

Original issue reported on code.google.com by andyned...@gmail.com on 30 Nov 2009 at 11:43

GoogleCodeExporter commented 9 years ago
The only way that you are going to know what column was clicked would be to put 
a
JavaScript event on the column. I think you are going to have to either create a
custom cell editor for each column to do it, or use jQuery and bind an event on 
load
of the page.

I wish I had a more direct answer for you but what you are tying to do is pretty
custom...although very possible.

Original comment by jeff.johnston.mn@gmail.com on 1 Dec 2009 at 3:03

GoogleCodeExporter commented 9 years ago
Thanks for you response. I'll try take a way to solve this problem with yours
indications. If I get it, I'll tell you and everybody. I hope.... :)

Original comment by presiden...@gmail.com on 1 Dec 2009 at 11:18

GoogleCodeExporter commented 9 years ago
At the end i solved the problem. I followed the indications (thanks so much 
Jeff!!)
and I've guided the solution with CellEditor. My custom class is...

import org.jmesa.util.ItemUtils;
import org.jmesa.view.editor.AbstractCellEditor;
import org.jmesa.view.html.HtmlBuilder;

public class FilaNoticiaPinchada extends AbstractCellEditor {

    @Override
    public Object getValue(Object item, String property, int rowcount) {
        Object value = ItemUtils.getItemValue(item, property);

        Object bean = ItemUtils.getItemValue(item, "news");
        Object nombreFichero = ItemUtils.getItemValue(bean, "fileName");
        HtmlBuilder html = new HtmlBuilder();
        html.div().onclick("javascript:document.getElementById('ruta').value='" +
fileName.toString() + "';
javascript:document.getElementById('action').value='create';
javascript:document.pag_frm.submit();").close();
        html.append(value);
        html.divEnd();
        return html.toString();
    }
}

In this way I show the same information, and I choose the columns I want to be 
clicked:

<jmesa:tableFacade toolbar="es.opencms.jmesa.ToolbarJMesa" id="jmesa_noticias"
stateAttr="restore" maxRows="5" maxRowsIncrements="5,10,15" items="${listado}"
var="noticias" editable="true" exportTypes="jexcel,pdfp,csv" >
    <jmesa:htmlTable>
        <jmesa:htmlRow uniqueProperty="id">
            <jmesa:htmlColumn property="checkbox" title="${checks}"  editable="true"
worksheetEditor="org.jmesa.worksheet.editor.CheckboxWorksheetEditor"
filterable="false" sortable="false" width="2%"/>
            <jmesa:htmlColumn property="fecha" title="Fecha" pattern="dd/MM/yyyy"
editable="false" cellEditor="org.jmesa.view.editor.DateCellEditor" 
sortable="true"
width="10%" headerClass="sortable" sortOrder="asc,desc,none"  />
            <jmesa:htmlColumn property="titular"
cellEditor="es.opencms.jmesa.ficha.FilaNoticiaPinchada" title="Titular"
sortable="true" editable="false" headerClass="sortable" 
sortOrder="asc,desc,none"
width="70%"/>
            <jmesa:htmlColumn property="prioridad"
cellEditor="es.opencms.jmesa.ficha.FilaNoticiaPinchada" filterable="true"
title="Prioridad" editable="false" sortable="true" headerClass="sortable"
sortOrder="desc,asc,none" width="8%"/>
            <jmesa:htmlColumn property="visible"
cellEditor="es.opencms.jmesa.ficha.FilaNoticiaPinchada" title="Visible"
editable="false" sortable="true" width="10%"
filterEditor="es.sopde.opencms.jmesa.filtros.FiltroBooleano"><img
src="<cms:link>${rutaImagen}dibujos/${noticias.mostrarVisible}</cms:link>"
/></jmesa:htmlColumn> 
        </jmesa:htmlRow>
    </jmesa:htmlTable>
</jmesa:tableFacade>

I hope this solution can be used to anyone with the same problem I had.

Original comment by andyned...@gmail.com on 1 Dec 2009 at 1:43

GoogleCodeExporter commented 9 years ago

Original comment by jeff.johnston.mn@gmail.com on 10 Mar 2011 at 10:08