문제

I have a EasyUI propertyGrid (which inherits dataGrid) with a few rows. I need that when user is editing a text field, when enter is pressed, editing is finished and onAfterEdit is called. EasyUI does not do this by default! Any solution?

도움이 되었습니까?

해결책

I had the same problem with treegrid, so i think you can use this code with propertyGrid also:

    onDblClickRow: function(row){
            if (editingId != undefined){
                $('#arbol_eui').treegrid('select', editingId);
                return;
            }

            if (row){
                editingId = row.id;
                pos = row.id;
                $('#arbol_eui').treegrid('beginEdit', editingId);
            }
            var ed = $(this).treegrid('getEditor',
                                     {index:editingId,field:'peso'});

            $(ed.target).focus().select().bind('keyup', function(e) 
            {
                var code = e.keyCode || e.which;
                if(code == 13) { //Enter keycode
                  //Trigger code to save row
                                      //This executes onAfterEdit event code
                  var t = $('#arbol_eui'); //My treegrid selector
                              t.treegrid('endEdit', editingId);
                              editingId = undefined; //editingId is a global var

                }
            });
        },

The key is to bind jquery event 'keyup' to the textbox editor for the cell at the 'onDblClickRow' event that also starts editing the row

Good luck

다른 팁

Try the datagrid-cellediting extension, it adds some functionality like this

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top