0
<sjg:gridColumn 
    name="progressivo" 
    index="progressivo" 
    title="ID" 
    sortable="false"
    formatter="integer"
    width="40"
    displayTitle="false"
    editable="true"
    hidedlg="true"
    editrules="{edithidden:false}"/>

I do NOT want to be able to edit the field, I do NOT want to show it in the edit Dialog, but I want to pass it to the action. My understanding is that I should use editable="true", hidedlg="true", editrules="{edithidden:false}" as specified above. But the field is still visible and editable in the dialog... anyone knows what is wrong with this code? thanks

2 Answers2

1

I don't see hidden="true" in the list of attributes of <sjg:gridColumn ...>. Moreover you use editrules="{edithidden:false}" instead of editrules="{edithidden:true }". Probably it's the problem.

In other words you need to have the column properties

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

described in the answer for example.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • If the `hidden: true` setting is used, isn't it not passed to the controller? – Mark Apr 30 '13 at 16:38
  • It will be sent to the server if you combine settings described [here](http://stackoverflow.com/a/9128231/315935). One uses already all correct options with exception `hidden: true` property. – Oleg Apr 30 '13 at 16:43
  • So the combination of `editable: false` and `edithidden:true` would still not display the value and transmit that value to the server? (You don't want the value displayed, but want it transmitted to the server, ex a PK value) – Mark Apr 30 '13 at 16:55
  • 1
    @Mark: the answer which I referenced contains `hidden: true, editable: true, editrules: { edithidden: true }, hidedlg: true`. I modified my answer one more time. `hidden: true` means - don't display column in grid. `hidedlg: true` means don't display in `columnCooser`. `editable: true` means to include the value from the column in Edit/Add form and sent the data later to the server. If the hidden data will be add to the form only if `editrules: { edithidden: true }` is additionally set. – Oleg Apr 30 '13 at 17:38
  • Ok, sorry to take up your time I just wanted to be clear, I had a requirement to show the information in the edit form(A Product name), but not have it editable, which is the top part of my answer below, would there have been a better way to have done so? – Mark Apr 30 '13 at 17:51
  • @Mark: There are many options how you can implement it. See the first part of [the answer](http://stackoverflow.com/a/8437659/315935) order [the answer](http://stackoverflow.com/a/5745168/315935) (click on "Add" button in the navigator bar). The best way depend on which kind of information you need to display, where you hold the data (in column, hidden column, outside of the grid) which you need to display and so on. You can describe the requirement on an example in new question and I could try to post what I think about the implementation. – Oleg Apr 30 '13 at 18:00
0

I think you have two options. I personally handled this requirement by defining my own custom edit options.

Ex:

    ... 
    editable: true, edittype: 'custom', editoptions: { custom_element: readOnlyTextBox, custom_value: readOnlyTextBoxValue } 
    ...

function readOnlyTextBox(value, options) {

    var el = document.createElement("input");
    el.type = "text";
    el.value = value;
    el.disabled = true; // "disabled";
    return el;
} //function readOnlyTextBox(value, options) {

function readOnlyTextBoxValue(elem, operation, value) {
    //console.log('Elem: ' + elem + '  Operation: ' + operation + '  Passed Value: ' + value + '  Value: ' + $(elem).val());        
    if (operation === 'get') {
        return $(elem).val();
    } else if (operation === 'set') {
        $(elem).val(value);
    }
} //function readOnlyTextBoxValue(elem, operation, value) {

The other option would be to define your own edit form handler and pass in the extra row item value:

        ....
        ondblClickRow: function (rowid) {
            EditCollectionItem(rowid, this)
        }, //ondblClickRow
        ....

function EditCollectionItem (rowid, grid){

    $(grid).jqGrid('editGridRow', rowid,
    {
        viewPagerButtons: false,
        editData: { ExtraDataKey: ExtraDataValue },
        afterShowForm: function (formid) {
        }, //afterShowForm
        afterComplete: function (response) {
        } //afterComplete
    }); //$this.jqGrid('editGridRow
}//function EditCollectionItem (rowid, grid){
Mark
  • 3,123
  • 4
  • 20
  • 31