0
votes

I'm using inline editing in my grid , I have some cases which i want to change the value of a cell inside a column. I'm changing it with setCell ,and it works good. my problem is that after the change the cell losts it's edit mode while all other cells of the row are in edit mode. I want to keep the cell in edit mode after i changed it.

for now what i did is saved the row and then selected it again and made in in edit mode - but i don't think it is a good solution - Is there a way to keep in edit mode while changin it?

Thank's In Advance.

2
Could you explain why it can be needed to save the contain of the cell which is in the editing mode. Typically if the user start changes in the cell he can click "Esc" to discard the changes. If the user click of "Enter" the changes will be saved, but in the case the row will be not more in the editing mode. Probably you use some another scenario for the saving the data. If you explain the scenario and describe where in which event handler you use the setCell call I could try to find a workaround for your situation. - Oleg
@Oleg:I will try to explain my situation-in my grid i have 2 cells which one of them is a code and the other is a description of the code. i have inside the code cell " $(elem).blur(function() " inside of it's 'editoptions:'. in this oblur function i make an ajax call to the server which gives me the description - then what i want to do is set the description cell with the value i got , and then continue editing the row i'm in - i want the next cell to get focue and continue editing. currently only the description cell loses it's editing and i want to keep it in edit mode, did u understand me? - user590586

2 Answers

5
votes

If you need to implement the behavior of dependency cells which are all in the editing mode you have to modify the cell contain manually with respect of jQuery.html function for example. If the name of the column which you want to modify has the name "description", and you use 'blur' event on another "code" column then you can do about the following

editoptions: {
    dataEvents: [
        {
            type: 'blur',
            fn: function(e) {
                var newCodeValue = $(e.target).val();
                // get the information from any source about the
                // description of based on the new code value
                // and construct full new HTML contain of the "description"
                // cell. It should include "<input>", "<select>" or
                // some another input elements. Let us you save the result
                // in the variable descriptionEditHtml then you can use

                // populate descriptionEditHtml in the "description" edit cell
                if ($(e.target).is('.FormElement')) {
                    // form editing
                    var form = $(e.target).closest('form.FormGrid');
                    $("#description.FormElement",form[0]).html(descriptionEditHtml);
                } else {
                    // inline editing
                    var row = $(e.target).closest('tr.jqgrow');
                    var rowId = row.attr('id');
                    $("#"+rowId+"_description",row[0]).html(descriptionEditHtml);
                }
            }
        }
    ]
}

The code will work for both inline and form editing.

The working example of dependent <select> elements you can find here.

0
votes

blur does not fire if value is changed and enter is pressed immediately without moving to other cell. So better is to use

editrules = new
{
custom = true,
custom_func = function( val, col ) { ... }
 },

and move this code from blur to custom_func as described in jqgrid: how send and receive row data keeping edit mode