EasyUI Forum
May 02, 2024, 11:39:07 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: Jquery error first time clicking propertygrid cell  (Read 8718 times)
codeguyross
Newbie
*
Posts: 15


View Profile Email
« on: March 28, 2014, 08:32:04 AM »

Hello,

The first time I click a cell in a property grid I always see the following error pop up in the console:
Uncaught TypeError: Cannot read property 'target' of undefined jquery.easyui.min.js:9152
  $.datagrid.$.extend.onClickRow jquery.easyui.min.js:9152
     jquery.easyui.min.js:7504
  x.event.dispatch   jquery-1.10.2.min.js:5
  x.event.add.v.handle   jquery-1.10.2.min.js:5

The line of code it is referencing in Jquery that is popping up the error is:
$(this).datagrid("getEditors",_6c5)[0].target.focus();


The problem is that $(this).datagrid("getEditors",_6c5) returns an empty array and thus generates an error when trying to access the '0' element.

Just in case it helps the following is my code for the propertygrid:

 $('#PropertyGrid').propertygrid(
        {
            onClickCell:function(rowIndex, field, value)
            {
               var rows = $('#PropertyGrid').propertygrid('getData').rows;
               var rowMap = new HashMap();
                for(var i=0;i<rows.length;i++)
                {
                    rowMap.add(rows.name, rows.value);
                }
                //allow user to change the name of certain nodes
                if( rows[rowIndex]['name'] == "name" && (rowMap.get("type") == "Int" || rowMap.get("type") == "Float" || rowMap.get("type") == "String"))
                {
                    if(rows[rowIndex]['editor'] == null)
                        rows[rowIndex]['editor'] = rows[rowIndex]['editor1'];
                    $('#PropertyGrid').propertygrid('beginEdit',rowIndex);
                }
                else if( rows[rowIndex]['name'] == "value" )
                {
                    
                        if(rows[rowIndex]['editor'] == null)
                            rows[rowIndex]['editor'] = rows[rowIndex]['editor1'];
                        $('#PropertyGrid').propertygrid('beginEdit',rowIndex);
                    
                }
            },
            onBeforeEdit:function(index,row){
                row.editing = true;
                updateActionsProperty(index);
            },
            onCancelEdit:function(index,row){
                row.editing = false;
                updateActionsProperty(index);
            }

        });
    function updateActionsProperty(index){
        $('#PropertyGrid').datagrid('updateRow',{
            index: index,
            row:{}
        });
    }


I find it bad form to modify the jquery code for any reason, so does anyone have any clue as to why jquery would throw and error on first time clicking of a cell in a propertygrid? Is this isolated to me or is it an error that others experience?

Lastly, for some unknown reason on the first click I see a movement crosshair when I click. Its only for a second but then it goes away. I only mention it because there may be some kind of movement event that is happening that I am no aware of that could be causing my error.

Thanks!
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: March 28, 2014, 06:43:35 PM »

The property grid has the build-in editing behavior, you don't need to achieve it by yourself. Please refer to these examples http://www.jeasyui.com/demo/main/index.php?plugin=PropertyGrid&theme=default&dir=ltr&pitem=
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!