Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
707 views
in Technique[技术] by (71.8m points)

jqgrid change cell value and stay in edit mode

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...