EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: garnold on October 19, 2016, 02:04:04 PM



Title: Mobile DataList
Post by: garnold on October 19, 2016, 02:04:04 PM
I'm trying to add a valueField to the datalist. I can create a list via the documentation just fine but I need more then just the text. I need to add a value connected to each row. This is an id for the item selected.


Title: Re: Mobile DataList
Post by: stworthy on October 19, 2016, 08:08:49 PM
You can bind any data rows on the datalist.
Code:
var data = [
{"group":"FL-DSH-01","item":"Tailless"},
{"group":"FL-DSH-01","item":"With tail"},
{"group":"FL-DSH-02","item":"Adult Female"},
{"group":"FL-DSH-02","item":"Adult Male"}
];
$(function(){
$('#dl').datalist({
data: data,
textField: 'item',
groupField: 'group',
textFormatter: function(value){
return '<a href="javascript:void(0)" class="datalist-link">' + value + '</a>';
},
onClickRow: function(index,row){
$('#p2-title').html(row.item);
$.mobile.go('#p2');
}
})
})