reakt
reakt

Reputation: 540

jqGrid Hidden Attribute for Modal Only

I'm using a modal pop up for adding new records, but I'm using inline for editing current records. When adding new records I want to hide some of the columns in the modal pop up.

If I set a column to hidden: true or editable: true then it also does not appear in the grid. What is the best way to hide columns in the add model pop up but still have them show in the grid?

Update to Oleg's Answer (setting editable attribute as function and testing hidden):

    {
            key: false, name: 'FINAL_DT', index: 'FINAL_DT',
            editable: true, formatter: 'date',
            formatoptions: { newformat: 'm-d-Y' },
            formoptions: {},
            editrules: { custom: true, custom_func: validDateCheck },
             editable: function (options) {
                if (options.mode === "addForm")
                {
                    hidden = true;
                }
            },
            editoptions: {
                dataInit: function (element) {
                    $(element).datepicker({
                        id: 'finalDt_Datepicker',
                        dateFormat: 'mm-dd-yy',
                        //minDate: new Date(2010, 0, 1),
                        maxDate: new Date(2020, 0, 1),
                        showOn: 'focus'
                    });
                }
            }
        }

Upvotes: 1

Views: 504

Answers (1)

Oleg
Oleg

Reputation: 221997

The solution depend on the version of jqGrid and from the fork, which you use. The most simple solution would be if you upgrade to the latest version (4.13.1) of free jqGrid (it's the fork, which I develop). If you installed old version via NuGet, then you should uninstall it and install free jqGrid from here. You can use it from CDN or download locally.

Free jqGrid allows to define editable attribute as a function. See the wiki article for details. You can test return "hidden" value from editable callback if options.mode === "addForm".

Upvotes: 1

Related Questions