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

kendo grid in inline editing mode with Dropdownlist required field.

1 Answer 324 Views
Grid
This is a migrated thread and some comments may be shown as answers.
afeef mabrouk
Top achievements
Rank 1
afeef mabrouk asked on 22 Aug 2013, 02:10 PM

I have a kendo grid in inline editing mode. When I press "Add new item" button, new row is added. some editable fields are ForeignKey column in the grid, if i fill the text fields in the new records without filling or select the dropdownlist fields for ForeignKey columns, a null values are set for ForeignKey  fields.

the question , how to enforce the user to select dropdownlist and make this field is required on "update" button click action.


i am using ASP.NET MVC 4.0 and Kendo UI for ASP.NET MVC Q2 2013.

Note: sample code for this issue if exist.

1 Answer, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 26 Aug 2013, 11:48 AM
Hi Afeef,

 
You can use for example the dataBinding event of the grid to check if there are any  "tr" elements with class "k-grid-edit-row" in the grid tbody to prevent the current event if the validation fails. Please check the example below:

function onDataBinding(e) {
    var row = this.tbody.find(".k-grid-edit-row");
    if (row.length > 0) {
        var validator = row.data("kendoValidator");
        if (!validator.validate()) {
            e.preventDefault();
        }
    }
 
    //remove the loading animation from the tbody
}
Kind Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
afeef mabrouk
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Share this question
or