EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: bvn on October 14, 2017, 12:51:06 PM



Title: Howto set values for datalist multiselect via ajax?
Post by: bvn on October 14, 2017, 12:51:06 PM
I want to use datalist for set roles to the user. When I click to the "Roles" button I show the window with datalist:

Code:
$('#button_roles').linkbutton({
onClick: function () {
var row = gridUsers.datagrid('getSelected');
var windowRoles = $('#window_roles').window({
title: 'Roles of '+row.username
});
var listRoles = $('#list_roles').datalist({
url: baseUrl+'admin/users/rolesrest/userroles',
textField: 'name',
valueField: 'id',
queryParams: {user_id: row.id},
singleSelect: false,
lines: true
});
windowRoles.window('open');
}
});

My restful returns data (as for datagrid) with all roles list. But I need to set selected some roles assigned to the user. What the best way to do it?

Thank you.


Title: Re: Howto set values for datalist multiselect via ajax?
Post by: stworthy on October 15, 2017, 05:00:56 PM
You can call 'selectRow' method to select your specified rows after loading data successfully.
Code:
$('#dl').datalist({
lines: true,
onLoadSuccess: function(data){
$(this).datalist('selectRow', ...);
}
})


Title: Re: Howto set values for datalist multiselect via ajax?
Post by: bvn on October 16, 2017, 09:17:24 AM
Thank you. It's useful.