jqueryjqgrid

jqGrid upgrade from 4.4.2 to 4.10 grouping issues


Without any change to the original code I seem to have a problem with inline editing:

  1. in my database the following field is varchar, but it seem that grid will not allow any text to be saved in it:
{name:'Sales Text',index:'sales_txt', width:60, sortable:false, 
    edittype: 'text',
    editable:true, classes: 'red',
    cellattr: function(rowId, val, rawObject) {
            if (String(val).toLowerCase() == 'done'){
                return 'style="color: #999"';
            }
    },
    editoptions: {
        size:9, 
        dataInit: function(el) { 
                $(el).datepicker({ 
                    dateFormat: "d M y" 
                });
        } 
    }
},

this field can contain a date in a format 15 Mar 2015 or a text i.e. TBA - there was no problem before.

  1. If I try to edit i.e. 2 row in a group of 5 rows - the edit opens on the last row in the group i.e. 5
ondblClickRow: function (row_id) {
    if(row_id != null) {
        if(row_id !== last_selected_row) {
            jQuery('#schedule').jqGrid('restoreRow',last_selected_row);
            jQuery('#schedule').jqGrid('saveRow',row_id);
            jQuery("#schedule").jqGrid('editRow',row_id, true, null, 
                function(){ $("#schedule").trigger("reloadGrid", [{current: true}]); },
                'xtras/schedule.php', 
                null,{},
                {},{}
            );
            last_selected_row = row_id; 
        } else {
            last_selected_row = row_id;
        }
    } 
},

not sure why is this happening. I tried to create a jsfiddle, but having problem making the grid read fake json data... anyway full code is here - http://jsfiddle.net/elen/5rzp3zzu/3/

P.S. not sure why stackoverflow doesn't preserve the code formatting...


Solution

  • It's important that every input item (from the server response) contains unique id. If you save the ids in some column then you can use key: true property in the column. It informs jqGrid to assign id attribute of every row of the grid (every <tr> element) to the value from the column.

    Additionally it's important to use unique name values in colModel, which don't contains any spaces. The names will be used to build ids of searching field and editing fields, but HTML5 don't allows to use spaces inside the ids. See here and here:

    The id attribute specifies its element's unique identifier (ID).

    The value must be unique amongst all the IDs in the element's home subtree and must contain at least one character. The value must not contain any space characters.