JqGrid - as hidden fields in edit form

I want to be able to submit fields to the edit form when the user tries to edit a line, but I do not want these fields to be editable. I want them to be just hidden, so they are sent to the server anyway.

For instance:

colModel :[
    {label: 'Game ID', name: 'game_id', editable:true},
    {label: 'Component ID', name: 'component_id', editable:true},
    {label: 'Table ID', name: 'table_id', editable:true},
],

This will pass them to the edit form (due editable:true), but unfortunately they will be editable by the user. I want to hide these fields so that the user cannot edit them.

How can i do this?

+3
source share
7 answers

EDIT

, , edittype. :

colModel :[
    {label: 'Game ID', name: 'game_id', editable:true, edittype:'custom',editoptions:{custom_element:myelem,custom_value:myval}},
    {label: 'Component ID', name: 'component_id', editable:true, edittype:'custom',editoptions:{custom_element:myelem,custom_value:myval} },
    {label: 'Table ID', name: 'table_id', editable:true, edittype:'custom',editoptions:{custom_element:myelem,custom_value:myval}}
]

myelem myval :

function myelem(value,options){
   return $('<input type="text" value="'+value+'" disabled="disabled"/>');
}

function myval(elem){
    return elem.val();
}

, afterShowForm.

( ), , afterShowForm ( "" ). . .

, , , . editable:true, , . , , - / , . afterShowForm :

afterShowForm: function(eparams){
    // change the selector appropriately
    $('#jqGrid input[name=game_id]').attr('type','hidden');
   // or $('#jqGrid input[name=game_id]').attr('disabled','disabled');
}
+5

jqGrid edithidden:

colModel: [
    { name: 'optionValue', key: true, index: 'optionValue', width: 55, editable: true,     hidden: true, editrules: { edithidden: false } },

false, /.

+6

, - onclickSubmit - .

var gr = jQuery("#table").jqGrid('getGridParam', 'selrow');
var row = jQuery("#table").getRowData(gr);

return { Id: row.Id };
+2

:

beforeShowForm: function (formid)
{
    $("#tr_name",formid).hide(); 
},
0

If the information is passed to your database editing functions, you can simply pass additional parameters through the URL

editurl:"database_edit.asp?user_id="+user_id

Not necessarily the best way - just another.

Greetings

Floor

0
source

try the following:

colModel: [
    { name: 'your_field_name', editable: true, hidden: true, search:false, editoptions: {style:'display:none;'}},
]
0
source

If you can trust the end user, you can simply add the editoptions attribute and set the disabled option to disabled as follows:

colModel: [
    { name: 'your_field_name', editable: true, hidden: true, search:false, editoptions: {'disabled':'disabled'}},
]
0
source

Source: https://habr.com/ru/post/1735156/


All Articles