开发者

Posting non-editable values in jqgrid

I'm using jqgrid 3.8.2 and the grid have many columns that are non-editable but still want to be posted to the server. How I can do that? (If I set editable:false then the field is not getting posted the th开发者_JS百科e server)


It seems to me that the column settings

hidden: true, editable: true, editrules: { edithidden: false }

will do what you need.


I realize this question is pretty old now but I needed to do this same thing today and the accepted answer doesn't actually answer the question. Sorry Oleg, you are still awesome. Anyway, if you have visible columns and are doing inline editing where some of those columns should not be editable the following worked for me.

Use these column setting

editable: true, edittype: 'custom', editoptions: { custom_element: readOnlyElement, custom_value: readOnlyValue}

and define these functions

function readOnlyElement(value, options) {
    return $('<span></span>', { text: value });
},

function readOnlyValue(elem, operation, value) {
    if (operation === 'get') {
        return $(elem).text();
    } else if (operation === 'set') {
        $('span', elem).text(value);
    }
}


About 'editable: "hidden"'...
This method is perfect until you change the contents of a cell. With 'editable:' hidden '', the jqgrid does not contain <input /> but aria-describedby which is less simple to target. ex:

without 'editable:"hidden"'
you target the input by its 'id '==>' $("#yourgrid #jqg3_your_field")

with 'editable:' hidden 'you target like that ... You need your current row id

rowID = $("#yourgrid").jqGrid('getGridParam', 'selrow');

$("tr[id='"+rowID+"'] [aria-describedby='yourgrid_your_field']>.u-jqgrid-cell-wrapper").html()

It's a lot less convenient :-)
Despite everything, it works very well ;-)


I see the answer in the comments for Oleg's answer by @singe3. Set,

editable: "hidden"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜