EasyUI Forum
April 28, 2024, 01:40:40 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Howto set values for datalist multiselect via ajax?  (Read 4660 times)
bvn
Newbie
*
Posts: 13


View Profile
« 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.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 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', ...);
}
})
Logged
bvn
Newbie
*
Posts: 13


View Profile
« Reply #2 on: October 16, 2017, 09:17:24 AM »

Thank you. It's useful.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!