EasyUI Forum
April 16, 2024, 04:03:35 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: How to prevent selection on certain datagrid column click?  (Read 5682 times)
bvn
Newbie
*
Posts: 13


View Profile
« on: October 26, 2017, 02:58:26 PM »

I have a datagrid with a checkbox column and options checkOnSelect: true and selectOnCheck: true. It's nice.
But I have another one column 'Actions' with linkbuttons. When I click that buttons it changes some states of the database record, but it changes selection state too and it's not nice Smiley

I need to prevent changing of selection when I click the button in 'Action' column of my datagrid. How can I do that?

Thank you.
Logged
jarry
Administrator
Hero Member
*****
Posts: 2260


View Profile Email
« Reply #1 on: October 26, 2017, 06:06:06 PM »

Stop the event bubbling when clicking on the button.
Code:
<th data-options="field:'actions',width:60,align:'center',formatter:formatActions">Actions</th>
<script type="text/javascript">
  function formatActions(){
    var s = '<a href="javascript:;" onclick="action();event.stopPropagation()">Button</a>';
    return s;
  }
  function action(){
    alert('action')
  }
</script>
Logged
bvn
Newbie
*
Posts: 13


View Profile
« Reply #2 on: October 31, 2017, 02:21:41 PM »

Thank you. I realized it in such way:
Code:
formatter: function (value, row, index) {
var out = '<a class="button_permission_read" data-options="selected:'+(value[0])+'" title="Read"></a>';
out += '<a class="button_permission_add" data-options="selected:'+(value[1])+'" title="Add"></a>';
out += '<a class="button_permission_edit" data-options="selected:'+(value[2])+'" title="Edit"></a>';
out += '<a class="button_permission_delete" data-options="selected:'+(value[3])+'" title="Delete"></a>';

return out;
}

Code:
onLoadSuccess: function (response) {
if (response.status == 'ok') {
$('.button_permission_read').linkbutton({
iconCls: 'icon-ok',
toggle: true
}).click(function (e) {
e.stopPropagation();
});
$('.button_permission_add').linkbutton({
iconCls: 'icon-add',
toggle: true
}).click(function (e) {
e.stopPropagation();
});
$('.button_permission_edit').linkbutton({
iconCls: 'icon-edit',
toggle: true
}).click(function (e) {
e.stopPropagation();
});
$('.button_permission_delete').linkbutton({
iconCls: 'icon-remove',
toggle: true
}).click(function (e) {
e.stopPropagation();
});
}
}

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!