Making a column with dropdown list editor required

5 posts, 1 answers
  1. AP
    AP avatar
    205 posts
    Member since:
    Apr 2010

    Posted 16 Aug Link to this post

    I'm just starting a project using PHP, rather than my more familiar ASP.NET MVC.

    I'm trying to get a grid with a pop-up editor working, containing a field bound to a drop-down list. I've (finally) got this working, but even though I've added the required validation to the field, and the field in the table is not nullable, the form is still allowing blank entries, which are populated as ''.

    The field is defined as:-

    $monthField = new \Kendo\Data\DataSourceSchemaModelField('Month');
       $monthField->type('string')
       ->validation(array('required'=>true));

     

    The column is :-

    $monthColumn = new \Kendo\UI\GridColumn();
                     $monthColumn->field('Month')
                                  ->editor('monthDropDownEditor');

     

    and the validator is set up as:-

    function monthDropDownEditor(container, options) {
        $('<input data-text-field="Month" data-value-field="Month" data-bind="value:' + options.field + '"/>')
            .appendTo(container)
            .kendoDropDownList({
                autoBind: false,
                dataSource: {
                    schema: {
                        data: "data"
                    },
                    transport: {
                        read: {
                            url: "dataSourceMonths.php?type=read",
                            type: "POST",
                            dataType: "json"
                        }
                    }
                },
                
                optionLabel: "Select month...",
            });
        }

     

    What do I need to do to make this a required field, and pop-up a validation message?

    Thanks

  2. Preslav
    Admin
    Preslav avatar
    233 posts

    Posted 18 Aug Link to this post

    Hello Andrew,

    Based on the provided information, I believe that you are correct and adding the required attribute to the input should resolve the issue.

    For example:

    $('<input required data-text-field="Month" data-value-field="Month" data-bind="value:' + options.field + '"/>')


    Regards,
    Preslav
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. AP
    AP avatar
    205 posts
    Member since:
    Apr 2010

    Posted 18 Aug in reply to Preslav Link to this post

    Thanks - that stops the form being submitted without a value being selected, but no message is displayed -even when adding a validationMessage attribute.

    How can I get a message to display?

  4. Answer
    Preslav
    Admin
    Preslav avatar
    233 posts

    Posted 21 Aug Link to this post

    Hi Andrew,

    Based on the information gathered here, I assume that the cause of this problem is a missing name attribute of the input. For more information, please refer to this forum post:
    and the relevant documentation:
    Please, give it a try and let me know if it works for you.
     

    Regards,
    Preslav
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  5. AP
    AP avatar
    205 posts
    Member since:
    Apr 2010

    Posted 24 Aug in reply to Preslav Link to this post

    Thanks, that worked
Back to Top