This is a migrated thread and some comments may be shown as answers.

Making a column with dropdown list editor required

4 Answers 328 Views
Grid
This is a migrated thread and some comments may be shown as answers.
AP
Top achievements
Rank 1
Iron
Iron
Veteran
AP asked on 16 Aug 2017, 08:48 PM

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

4 Answers, 1 is accepted

Sort by
0
Preslav
Telerik team
answered on 18 Aug 2017, 03:16 PM
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.
0
AP
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 18 Aug 2017, 06:08 PM

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?

0
Accepted
Preslav
Telerik team
answered on 21 Aug 2017, 02:22 PM
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.
0
AP
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 24 Aug 2017, 04:44 PM
Thanks, that worked
Tags
Grid
Asked by
AP
Top achievements
Rank 1
Iron
Iron
Veteran
Answers by
Preslav
Telerik team
AP
Top achievements
Rank 1
Iron
Iron
Veteran
Share this question
or