EasyUI Forum
April 27, 2024, 12:26:25 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: v1.3.2 datagrid deleteRow Bug  (Read 14866 times)
gasoline
Newbie
*
Posts: 3


View Profile
« on: March 26, 2013, 03:11:48 AM »

idField:'objectID',
columns:[[
         {field:'username',title:'username',width:200,sortable:true},
         {field:'action',title:'',width:50,formatter:function(value,row,rowIndex){
            var $_buttons = $("<div><a href='#' class='easyui-linkbutton' onclick='OPT_SYSTEMUSER_REMOVE("
                        + row.objectID + ");'></a></div>");
            $_buttons.find('.easyui-linkbutton').linkbutton({plain:true,iconCls:"icon-remove"});
            return $_buttons.html();
         }}
      ]],
-------------------------------------------
notice: the field 'action'
-------------------------------------------
OPT_SYSTEMUSER_REMOVE = function( _objectID ){
   $('#dataTabAll').datagrid('selectRecord',_objectID);
   var row = $('#dataTabAll').datagrid('getSelected');
   var index = $('#dataTabAll').datagrid('getRowIndex',row);
   $('#dataTabAll').datagrid('unselectRow',index);
   $('#dataTabAll').datagrid('deleteRow',index);
};
------------------------------------------
Bug Desc:
When I remove the last one, tip:" Uncaught TypeError: Cannot read property 'action' of undefined  " And Remove successfully.
« Last Edit: March 26, 2013, 03:14:49 AM by gasoline » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: March 26, 2013, 08:43:29 AM »

To solve this issue, stop the event bubbling when clicking the linkbutton

Code:
onclick=\"OPT_SYSTEMUSER_REMOVE('"
                        + row.objectID + "');event.stopPropagation?event.stopPropagation():window.event.cancelBubble=true;\"

or delay the delete action

Code:
		OPT_SYSTEMUSER_REMOVE = function( _objectID ){
   $('#dg').datagrid('selectRecord',_objectID);
   var row = $('#dg').datagrid('getSelected');
   var index = $('#dg').datagrid('getRowIndex',row);
   $('#dg').datagrid('unselectRow',index);
   setTimeout(function(){
   $('#dg').datagrid('deleteRow',index);
   },0);
};
Logged
gasoline
Newbie
*
Posts: 3


View Profile
« Reply #2 on: March 26, 2013, 06:26:56 PM »

tks, I selected the second way and It`s OK.
But I don`t know reason.

If it`s not bug. do I need to remove this topic?
« Last Edit: March 26, 2013, 06:29:31 PM by gasoline » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: March 26, 2013, 06:41:17 PM »

The updated datagrid plugin can be download from http://www.jeasyui.com/easyui/plugins/jquery.datagrid.js. Thus delay deleting action is not need.
Code:
OPT_SYSTEMUSER_REMOVE = function( _objectID ){
var index = $('#dg').datagrid('getRowIndex',_objectID);
$('#dg').datagrid('deleteRow',index);
};
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!