institut-de-genomique / Ultimate-DataTable

This AngularJS directive generate a HTML table with build-in fonctionnality like save, edit, remove, pagination etc...
http://institut-de-genomique.github.io/Ultimate-DataTable/
45 stars 26 forks source link

Error handling in Ultimate-DataTable #51

Open PratibhaP opened 4 years ago

PratibhaP commented 4 years ago

Following is my code


  var datatableConfig = {
    "name": "Prescription_Table",
    "columns": [{
            "header": "Name",
            "property": "name",
            "edit": true,
             "required": true,
            "type": "text"
        },
        {
            "header": "Quantity",
            "property": "quantity",
            "edit": true,
            "format": "number",
             "required": true,
            "type": "number"
        },
        {
            "header": "Duration",
            "property": "duration",
            "edit": true,
            "format": "number",
           "required": true,
             "type": "number"
        }
    ],
    "edit": {
        "active": true,
        "columnMode": false,
        "showButtonColumn": false,
        "callback": function(datatable, errorsNumber) {}
    },
    "filter": { "active": true, "highlight": true, "columnMode": false },
    "save": {
        "active": true,
        "mode": 'local',
        "withoutEdit": false,
        "showButton": true,
        "callback": function(datatable, errorsNumber) {}
    },
    "add": { "active": true, "showButton": true },
    "compact": true,
    "hide": { "active": true },
    "pagination": { "active": false },

    "name": ["Name is required"],
    "quantity": ["bad format : only [0-9] values allowed"],
    "duration": ["bad format : only [0-9] values allowed"],

    "messages": {
        "active": true, //Active or not
        "errorClass": 'alert alert-danger', //Set the class when their is errors
        "successClass": 'alert alert-success', //Set the class when their is success
        //Set the error key to be i18n
        "errorKey": { save: 'datatable.msg.error.save', remove: 'datatable.msg.error.remove' },
        //Set the success key to be i18n
        "successKey": { save: 'datatable.msg.success.save', remove: 'datatable.msg.success.remove' },
        //Current text
        "text": 'Provide valid input.',
        //current class
        "clazz": '',
        "transformKey": function(key, args) {} //the function that transform the key
    }
};
           //Init the datatable with his configuration
           $scope.datatable = datatable(datatableConfig);
           //Set the data to the datatable
           $scope.datatable.setData(datatableData);

Can you please tell me what is I am doing wrong? I am unable to see error messages for particular fields for required and pattern error