JEasyUI: Bug Fixing for perpertygrid

The propertygrid is really a nice plugin. However, you may encounter error if load it with ajax method as below.

$('#p_prop').panel('refresh', './property_data.php');	

When editing a loaded property field, user abort the action by refreshing the property panel again. You will get below error:

Reason:

Inside stopEditing which is called during propertygrid initialization, the opts line failed, due to currTarget is global variable which is not reset when reloading by ajax

function stopEditing(target){
		var t = $(target);
		if (!t.length){return}
		var opts = $.data(target, 'propertygrid').options;
		opts.finder.getTr(target, null, 'editing').each(function(){
			var index = parseInt($(this).attr('datagrid-row-index'));
			if (t.datagrid('validateRow', index)){
				t.datagrid('endEdit', index);
			} else {
				t.datagrid('cancelEdit', index);
			}
		});
		opts.editIndex = undefined;
	}

  

 Solution:

function buildGrid(target){
		var state = $.data(target, 'propertygrid');
		var opts = $.data(target, 'propertygrid').options;
		currTarget = undefined; //bug fixing for ajax reload

  

posted @ 2016-03-08 12:37  rongbin  阅读(230)  评论(0编辑  收藏  举报