简体   繁体   中英

How to add validation for ng2-smart-table in angular 7?

I am using ng2-smart-table in order to add employee details.I have fields like name,mobile ,email etc.I want to add validation for each fields in the table.I have searched for validation in google but was not able to find any.Can anyone help me to solve this issue.

Below are the codes for creating ng2-smart-table

<div class="card-body">
    <ng2-smart-table [settings]="settings" [source]="employeeList" 
    style="font-size: 14px;"></ng2-smart-table>
</div>

add: { addButton: 'Add Employee', createButton: 'Save ' },
                columns: {
                    Employee: {
                        title: 'Employee Name',
                        filter: false
                    },
                    UID: {
                        title: 'Employee ID',
                        filter: false
                    },
                    Mobile: {
                        title: 'Mobile',
                        filter: false
                    },
                    Email: {
                        title: 'Email Id',
                        filter: false
                    },
                    Address: {
                        title: 'Address',
                        filter: false
                    },
                    State: {
                        title: 'State',
                        filter: false
                    }
                },
                attr: {
                    class: 'table table-bordered'
                }
Should show error messages for invalid fields in the table

As far as I remember they do not have any documented way to do that. But you can try this modification, it's much more configurable:

HERE

But, If you still want to use ng2-smart-table , you are probably will need to make the custom validation in your TS/JS code using the HTMLElement or dynamic classes .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM