EasyUI Forum
May 14, 2024, 10:12:16 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: Problem to edit datagrid  (Read 10274 times)
haltman
Newbie
*
Posts: 5


View Profile
« on: April 26, 2012, 06:48:11 AM »

I've tried to use tutorial example for inline datagrid editing but seems not work, i see the field action added but pushing edit or cancel nothing happen, any idea?

here follow my code:

Code:
$("#tt").datagrid({
                        title: "log",
                        singleSelect:true, 
                            idField:'contratto',
                        url: stringa,
                    columns: [[{field:'utente',title:'Utente', width:80, sortable:true, editor:'text'},
                              {field:'contratto',title:'Contratto', width:80, sortable:true, editor:'text'},
                              {field:'login',title:'Login', width:80, sortable:true, editor:'text'},
                              {field:'piattaforma',title:'Piattaforma', width:80, sortable:true, editor:'text'},
                              {field:'azione',title:'Azione', width:80, sortable:true, editor:'text'},
                              {field:'data',title:'Data - ora', width:80, sortable:true, editor:'text'},
                              {field:'note',title:'Note', width:80, sortable:true, editor:'text'},
                              {field:'action',title:'Action',width:70,align:'center', 
                                    formatter:function(value,row,index){ 
                                    if (row.editing){ 
                                            var s = '<a href="#" onclick="saverow('+index+')">Save</a> '; 
                                            var c = '<a href="#" onclick="cancelrow('+index+')">Cancel</a>'; 
                                            return s+c; 
                                        } else { 
                                            var e = '<a href="#" onclick="editrow('+index+')">Edit</a> '; 
                                            var d = '<a href="#" onclick="deleterow('+index+')">Delete</a>'; 
                                            return e+d; 
                                        } 
                                    } 
                                } 
                             ]],
                             onBeforeEdit:function(index,row){ 
                                 row.editing = true; 
                                 updateActions(); 
                             }, 
                             onAfterEdit:function(index,row){ 
                                 row.editing = false; 
                                 updateActions(); 
                             }, 
                             onCancelEdit:function(index,row){ 
                                 row.editing = false; 
                                 updateActions(); 
                             }, 
                             pagination:true
                    });
                        function updateActions(){ 
                            var rowcount = $('#tt').datagrid('getRows').length; 
                            for(var i=0; i<rowcount; i++){ 
                                $('#tt').datagrid('updateRow',{ 
                                    index:i, 
                                    row:{action:''} 
                                }); 
                            } 
                        } 
                        function editrow(index){ 
                            $('#tt').datagrid('beginEdit', index); 
                        }
                        function deleterow(index){ 
                            $.messager.confirm('Confirm','Are you sure?',function(r){ 
                                if (r){ 
                                    $('#tt').datagrid('deleteRow', index); 
                                } 
                            }); 
                        } 
                        function saverow(index){ 
                            $('#tt').datagrid('endEdit', index); 
                        }
                        function cancelrow(index){ 
                            $('#tt').datagrid('cancelEdit', index); 
                        } 

thanks in advance
ciao
h.
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!