volosoft / jtable

A JQuery plugin to create AJAX based CRUD tables.
http://www.jtable.org
1.1k stars 506 forks source link

Hiding field based on other field value #1310

Open pamatulli81 opened 10 years ago

pamatulli81 commented 10 years ago

Hi,

i am trying to get rid with it. I have a field FILE_OPEN which should be shown only if the CDOC_FILENAME is not empty, but it not works. Have i made something wrong ?

      FILE_OPEN: {
                                title: '',
                                width: '1%',
                                sorting: false,
                                create: false,
                                edit: false,
                                list: true,
                                dependsOn: 'CDOC_FILENAME',  
                                options: function (data) {
                                    if (data.source == "list")
                                    {

                                        thisbox =  data.form.find('[name=\"FILE_OPEN\"]')
                                        if(data.dependedValues['CDOC_FILENAME'] != '')
                                        {
                                            thisbox.prop('disabled', false).parents(".jtable-input-field-
                                            container").first().slideUp();
                                         }
                                        else
                                        {
                                            thisbox.prop('disabled', true).parents(".jtable-input-
                                           field-container").first().slideDown(); //Hide Element

                                        }
                                        return <img src.....>

                                    }
                                }
                            }

                        },
misterparsons commented 10 years ago

Hi, I think you are over complicating things. It does not look like you are using cascading dropdown lists which is the purpose of dependsOn. I think you just need a simple display function.

FILE_OPEN: {
                                title: '',
                                width: '1%',
                                sorting: false,
                                create: false,
                                edit: false,
                                list: true,
                                display: function (data) {
                                    if (data.record.CDOC_FILENAME != '' ) {
                                     return <img src.....>;
                                    }
                                    else {
                                        return '';
                                    }
                                }
                            }
                        },

Good Luck Malcolm