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

Make grid fields required when using DropDownList

5 Answers 463 Views
Grid
This is a migrated thread and some comments may be shown as answers.
M
Top achievements
Rank 1
M asked on 27 Oct 2012, 12:05 PM
I have an inline editable grid with one of the columns rendered as a DropDownList (options from another remote datasource)

I've set the validation properties in the grid's schema so that the field attached to the dropdown is required, but htis isn't working. Users are able to just skip past the dropdown and save (or at least try to) the record.

Am I missing something?

Thanks

5 Answers, 1 is accepted

Sort by
0
M
Top achievements
Rank 1
answered on 31 Oct 2012, 11:13 AM
Can somebody help me with this?

All I'm trying to do is make sure that users actually select something from the DropDownList before saving.

The DropDownList is working fine: when something is selected, the correct data is being saved. But I can't prevent users trying to save without making a selection.

In the Grid dataSource schema I have:
schema: {
    data:'data',
    total:'count',
    model: {
        id: "id",
        fields: {
            id: { type: "number", editable: false, nullable: true },
            contract_id: { type: "number", validation: { required: true }, defaultValue: null },
            // other fields removed for clarity
        }
    }
},

The columns are setup as:
columns: [
    { field: "contract_id", title: 'Contract', width: 200, editor: contractDropDownEditor, template:"#= ref_number # : #= description #" },
]

The contractDropDownEditor function:
function contractDropDownEditor(container, options)
{
    $('<input data-text-field="text" data-value-field="contract_id" data-bind="value:' + options.field + '"/>')
    .appendTo(container)
    .kendoDropDownList({
        autoBind: false,
        dataSource: contractDataSource
    });
}

I'm sure this should be simple. Can somebody please point out where I'm going wrong?

Thanks
0
Ahmed
Top achievements
Rank 1
answered on 22 May 2013, 09:22 PM
+1
0
Zachary
Top achievements
Rank 1
answered on 03 Apr 2014, 12:25 AM
I can't get a validation tooltip to show, but simply adding a required attribute does make the update button stop:

‚Äč
<input data-text-field="text" data-value-field="contract_id" data-bind="value:' + options.field + '" required />
0
Alexander Valchev
Telerik team
answered on 03 Apr 2014, 09:03 AM
Hello guys,

Please check the columns.editor documentation.
Inside you find an explanation why the validation does not show up and what should be done in case a Kendo widget is used as an editor. Code sample is included.

@Zachary - please check the 2nd code snippet

Regards,
Alexander Valchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Zachary
Top achievements
Rank 1
answered on 03 Apr 2014, 04:27 PM
Alexander,

Thank you for your reply. I had tried k-invalid-msg but forgot to set the name attribute on the input element.

Zachary
Tags
Grid
Asked by
M
Top achievements
Rank 1
Answers by
M
Top achievements
Rank 1
Ahmed
Top achievements
Rank 1
Zachary
Top achievements
Rank 1
Alexander Valchev
Telerik team
Share this question
or