Row reordering - set order field as hidden in editor ?

Row reordering - set order field as hidden in editor ?

crush123crush123 Posts: 417Questions: 126Answers: 18

Is it possible to hide the order field in editor ?

I realise it is read only, but if hidden, users would not think to try and change it.

I tried adding type: 'hidden' in my editor instance, but get an error message on reordering - 'Cannot read property 'prop' of undefined'

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    Can you link to the page showing the error please. If that isn't possible we might be able to help if you show your code. The hidden field type sounds like it should be perfect in this case.

    Allan

  • crush123crush123 Posts: 417Questions: 126Answers: 18

    still on test server for now, will upload if this code snippet doesn't help

    if i remove the line type: "hidden", it works fine

    editor = new $.fn.dataTable.Editor( {
    
        ajax: "/ajax/galleries.php",
        table: "#example",
        fields: [ {
                label: "Order:",
                name: "refgallery.ListOrder",
                type: "hidden"
            }, {
                label: "Description:",
                name: "refgallery.GalleryDescription"
            }, {
                label: "Tooltip:",
                name: "refgallery.GalleryTooltip"
            }, {
                label: "Show On Menu:",
                name: "refgallery.ShowOnMenu",
                type:      "checkbox",
                separator: "|",
                options:   [
                    { label: '', value: 1 }
                ]
            }, {
                label: "Show On Slideshow:",
                name: "refgallery.ShowOnSlideshow",
                type:      "checkbox",
                separator: "|",
                options:   [
                    { label: '', value: 1 }
                ]
            }
        ]
    
        } );
    

    I appreciate that the code above is not finalised, as i either want to hide only on edit, (not on create), or automatically increment to the next number on create

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Answer ✓

    I must confess I don't understand why it being a hidden field would have any effect on it compared to a visible field. I'm afraid I would need a link.

    Allan

  • crush123crush123 Posts: 417Questions: 126Answers: 18
    edited October 2015

    Thanks Allan

    As instructed, changed lines Editor 1.5.1

    from

    fieldTypes.hidden = $.extend( true, {}, baseFieldType, {
    create: function ( conf ) {
        conf._val = conf.value;
        return null;
    },
    
    get: function ( conf ) {
        return conf._val;
    },
    
    set: function ( conf, val ) {
        conf._val = val;
    }
    

    } );

    to

    fieldTypes.hidden = {
    create: function ( conf ) {
        conf._val = conf.value;
        return null;
    },
    
    get: function ( conf ) {
        return conf._val;
    },
    
    set: function ( conf, val ) {
        conf._val = val;
    }
    
    };
    

    I also used the code snippet in another thread to set a default value to the next number in sequence on create

    fields: [ {
                label: "Order:",
                name: "refgallery.ListOrder",
                type: "hidden",
                def: function () {
                var nextSeqNum = table
                    .column(0)
                    .data()
                    .sort()
                    .reverse()[0];
                return parseInt(nextSeqNum) + 1;
                }
            }
    ...
    ]
    
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    Sounds good. This change will be in the next Editor release (1.5.2).

    Allan

This discussion has been closed.