Foros de discusión

DataTable row selection i aui 3.0.x

Szászvári Péter, modificado hace 7 años.

DataTable row selection i aui 3.0.x

New Member Mensajes: 2 Fecha de incorporación: 1/09/16 Mensajes recientes
Hi Everyone,
I'm relatively new to Liferay. I try to create a DataTable with visible row selection. The user should be able to select a row, it should be marked as such, and the program should be able to read later the id of the selected row.
I need to do it without a selection column with checkboxes.
I have spent several hours on this, I have working version of the table with data, but was not able to find example of row selection.
I have found good example code for AUI v. 1.5 http://alloyui.com/versions/1.5.x/examples/datatable/real-world/ but it does not help me in 3.0.x

So please let me know how can I make visible row selection in v 3.0.x

Thank you
Folken Fanel, modificado hace 7 años.

RE: DataTable row selection i aui 3.0.x

New Member Mensajes: 3 Fecha de incorporación: 8/09/16 Mensajes recientes
If you find out, please share with us. I have the same question.
Folken Fanel, modificado hace 7 años.

RE: DataTable row selection i aui 3.0.x

New Member Mensajes: 3 Fecha de incorporación: 8/09/16 Mensajes recientes
Found a solution:
var rowUID = DataTable.get('selection').rows[0].guid();
DataTable.getRecord(uid).toJSON();
Szászvári Péter, modificado hace 7 años.

RE: DataTable row selection i aui 3.0.x

New Member Mensajes: 2 Fecha de incorporación: 1/09/16 Mensajes recientes
Folken Fanel:
Found a solution:
var rowUID = DataTable.get('selection').rows[0].guid();
DataTable.getRecord(uid).toJSON();


Thank you. This would solve the getting the selected row part. But my first concern was, how to make it visible. So how to put a highlight on the last selected row that stays there and changes when another row is selected. As far as I understand, the highlight module can be configured, but for mouse-over not for selection. I might be wrong on that. Anyway I don't even understand how to configure the highlight module at all.
thumbnail
Kyle Joseph Stiemann, modificado hace 7 años.

RE: DataTable row selection i aui 3.0.x

Liferay Master Mensajes: 760 Fecha de incorporación: 14/01/13 Mensajes recientes
Hi Szászvári,
I've answered this question on StackOverflow:

You need to use the DataTableHighlight module with type: 'rows' instead:

YUI().use('aui-datatable', 'aui-datatable-highlight',
function(Y) {

/* ...your code here... */

var dataTable = new Y.DataTable({
/* ...your code here... */
plugins: [{
cfg: {
type: 'rows'
},
fn: Y.Plugin.DataTableHighlight
}]

}).render('#myDataTable');
});

- Kyle