Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
Unable to edit a row
Tags: Edit row
14/12/2011
11:36
Avatar
Radel
Member
Members
Forum Posts: 3
Member Since:
14/12/2011
sp_UserOfflineSmall Offline

Heya Folks,

I ve some troubles at enabling row-editing by events (and the other more basically as basic example or custom example) following step by step as:

http://www.trirand.com/blog/jq.....  —-> Row editing (new)

I tried some ways, im just desperated. Here is my code:

—————————————————————

        jQuery(document).ready(function(){
            var lastsel;
                $(function(){
                    $("#list").jqGrid({        
                        url:'CargaTabla.action', //Calls an struts 2 action. Returned JSON is OK
                        datatype: 'json',
                        mtype: 'POST',
                        colNames:['ID','Name', 'Address', 'Age'],
                        id: "id",
                        colModel :[    
                            {name: 'id', hidden:true},
                            {name:'nombre', index:'nombre', width:120, editable:'true', edittype:'text', edithidden:false},
                            {name: 'direccion', index:'direccion', width:150, editable:'true', edithidden:false, edittype:'text'},
                            {name:'edad', index:'edad', width:90, editable:'true', edithidden:false}
                        ],
                        jsonReader: {
                            repeatitems: false,
                            root: "gridModel",
                            id: "0″, //IMPORTANT: Setting id = 0 indicates that ID will be the first column. Its cause i let it hidden.
                            cell: "" //Without no more information for cell.
                        },
                        pager: '#pager',
                        rowNum:10,
                        multiselect: false,
                        height: "100%",
                        rowList:[10,20,30],
                        sortname: 'id',
                        viewrecords: true,
                        editurl: "CargaTabla.jsp",
                        caption: 'Tabla TRY2',

                        //MOST IMPORTANT PART OF THE CODE
                         onSelectRow: function(id){
                            if(id && id!==lastsel){
                                alert('1');
                                jQuery('#list').jqGrid('restoreRow',lastsel);
                                alert('2');
                                jQuery('#list').jqGrid('editRow',id,true,null,onSaveSuccess);
                                alert('3');
                                lastsel=id;
   
                            }
                        }
                    });
                });
                function onSaveSuccess(respuesta){
                alert('hecho ' + respuesta);
                }
                
                jQuery("#list").jqGrid('navGrid',"#pager",{edit:false,add:false,del:false});

               //Just try if setSelection works fine, and it is.
                jQuery("#bedata").click(function(){
                    jQuery("#list").setSelection("2″); //This select correctly the row with id = 2.
                });
                jQuery('#list').jqGrid('editRow',2);
                
        });
        </script>

————————————————————–

Table is correctly seted with data, and I can use this last function correctly.

The problem is that the selected row doesnt change to "edit mode". Check out the alerts at   onSelectRow: function(id){…. They execute correctly. JS debugger has no errors to show. Whats wrong? I tried with a separate .jsp page. Im just desperate.

Any suggestion?

Thank you.

14/12/2011
12:45
Avatar
Radel
Member
Members
Forum Posts: 3
Member Since:
14/12/2011
sp_UserOfflineSmall Offline

Hello,

Solved, by configuring jsonreader as:

-----------------

                    jsonReader: {
                        root: 'gridModel',
                        id: '0',
                        cell :"",
                        repeatitems: false
                    }

----------------------

I dont understand the parameter "repeatitems", event consulting the documentation. Could anyone explain me whats with this parameter? Why if I turn it  on true (default value), only appear empty rows?

Thank you.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
62 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information