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

Dropdown Validator

2 Answers 76 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Curt
Top achievements
Rank 1
Curt asked on 13 Jun 2012, 12:34 PM
I am trying to get a required field validator working with a grid dropdown.  I cannot get the error message to show.  Has anyone done something like this?  Here is an code example of how I defined the field in my datasource model.

DestinationCountry: {
  defaultValue:{Name: "", CountryId: null},
   validation: {
                     custom: function(input) {
                                 // set the custom message
                                 var boundTo = input.data("bind");
 
                                 if (typeof boundTo != "undefined" && boundTo == "value: DestinationCountry"){
                                    input.attr("data-custom-msg", "Please select Country");
                                    var isValid = (input.val() != "" && input.val() > 0);
                                    if (!isValid){
                                        alert("Please select Country");
                                    }
                                    return isValid;
                                 } else {
                                    return true;
                                 }
                                }}}

2 Answers, 1 is accepted

Sort by
0
Curt
Top achievements
Rank 1
answered on 13 Jun 2012, 12:47 PM
Here is the dropdown editor used:

var dropdownlist = $('<input data-text-field="Name" data-value-field="CountryId" data-bind="value: DestinationCountry"/>').appendTo(container).kendoDropDownList({
                autoBind: false,
                dataSource: {
                    transport: {
                        read: function (options) {
                            options.success(self.Model.Countries);
                        },
                    },
                    schema: {
                        model: {
                            id: 'CountryId'
                        }
                    }
                },
                optionLabel: "Select Country"
            }).data("kendoDropDownList");
0
Curt
Top achievements
Rank 1
answered on 20 Jun 2012, 01:16 PM
Admin, can you explain how to implement validation in a grid for a dropdown?
Tags
Grid
Asked by
Curt
Top achievements
Rank 1
Answers by
Curt
Top achievements
Rank 1
Share this question
or