Foros de discusión

<alloy:datatable> and search

Nestor cruz, modificado hace 7 años.

<alloy:datatable> and search

Junior Member Mensajes: 48 Fecha de incorporación: 15/02/15 Mensajes recientes
Hello people

Again go for your help.

My question is how should search in a datatable, for this I am using the following plugins


<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.12/css/jquery.dataTables.css">
<script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.12/js/jquery.dataTables.js"></script>
<link type="text/css" href="css/ui-lightness/jquery-ui-1.8.21.custom.css" rel="stylesheet">
<script type="text/javascript" src="scripts/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="scripts/jquery-ui-1.8.21.custom.min.js"></script>


use the function to search


<script type="text/javascript">
		$(document).ready(function() {
			var table = $('#tarifaImpuestoForm\\:listaTarifaImpuestos').DataTable();
			$('#tarifaImpuestoForm\\:myInput').on('keyup', function() {
				table.search(this.value).draw();
			});
		});
</script>


and the code of my datatable

<alloy:inputtext id="myInput" />
			<alloy:datatable id="listaTarifaImpuestos" var="tarifaImpuesto" selectionmode="radio" value="#{tarifaImpuestoBacking.tarifaImpuestoDataModel}">

				<alloy:column headertext="#{i18n['impuesto']}">
					<alloy:outputtext value="#{tarifaImpuesto.impuesto}"></alloy:outputtext>
				</alloy:column>

				<alloy:column headertext="#{i18n['descripcion']}">
					<alloy:outputtext value="#{tarifaImpuesto.descripcion}"></alloy:outputtext>
				</alloy:column>

				<alloy:column headertext="#{i18n['codigo']}">
					<alloy:outputtext value="#{tarifaImpuesto.codigo}"></alloy:outputtext>
				</alloy:column>

				<alloy:column headertext="#{i18n['porcentaje']}">
					<alloy:outputtext value="#{tarifaImpuesto.porcentaje}"></alloy:outputtext>
				</alloy:column>

				<alloy:column headertext="#{i18n['tarifaEspecial']}">
					<alloy:outputtext value="#{tarifaImpuesto.tarifaEspecial}"></alloy:outputtext>
				</alloy:column>

				<alloy:column headertext="#{i18n['fechaModificado']}">
					<alloy:outputtext value="#{tarifaImpuesto.createDate}"></alloy:outputtext>
				</alloy:column>
			</alloy:datatable>


When you run the code I have no error and no action

From and I thank you for the help
thumbnail
Kyle Joseph Stiemann, modificado hace 7 años.

RE: <alloy:datatable> and search

Liferay Master Mensajes: 760 Fecha de incorporación: 14/01/13 Mensajes recientes
Hi Nestor,
It seems like you are looking for a feature like dataTable filtering. If so, please vote for and watch this feature request for dataTable filtering.

Related to your current example, it seems like you are using jQuery with our alloy:dataTable. This should work in theory although we've never tried it. I don't think it would be compatible with pagination, and it may cause some issues with differences between the client side and server side dataTable representations. However, it seems like your example should work. Could you post some sample data and a bean to make it easier for us to try your code?

- Kyle
Nestor cruz, modificado hace 7 años.

RE: <alloy:datatable> and search

Junior Member Mensajes: 48 Fecha de incorporación: 15/02/15 Mensajes recientes
Hello and thanks for answering

Sorry for delay, but here I leave a project so that you can try.

I await your comments
thumbnail
Kyle Joseph Stiemann, modificado hace 7 años.

RE: <alloy:datatable> and search

Liferay Master Mensajes: 760 Fecha de incorporación: 14/01/13 Mensajes recientes
Hi Nestor,
I think you might be running into FACES-2580. Please try either changing h:head and h:body to alloy:head and alloy:body or adding alloy.js to h:head:

<alloy:outputScript library="liferay-faces-alloy" name="alloy.js" target="head" />

If things are still not working after that change, please update your project with the jQuery CSS and JS resources included so that I can test it.

- Kyle
Nestor cruz, modificado hace 7 años.

RE: <alloy:datatable> and search

Junior Member Mensajes: 48 Fecha de incorporación: 15/02/15 Mensajes recientes
Hi Kyle

I tried the suggestion but still does not work
thumbnail
Kyle Joseph Stiemann, modificado hace 7 años.

RE: <alloy:datatable> and search

Liferay Master Mensajes: 760 Fecha de incorporación: 14/01/13 Mensajes recientes
Okay, please update your project with the jQuery CSS and JS resources included so that I can test it.

- Kyle