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

How do I make a cell required when working with the inline editor?

6 Answers 3102 Views
Grid
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 18 Mar 2013, 03:38 PM
Sorry for the stupid question...The demos don't have any code...Working with MVC3 razor. Thanks.

6 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 19 Mar 2013, 12:56 PM
Hi John,


You could define a property as required in the model definition with the DataAnnotations required attribute. Additional information can be found on the following msdn page.
E.g.
[Required]
[DisplayName("Unit price")]
[DataType(DataType.Currency)]
[Range(0, int.MaxValue)]
public decimal? UnitPrice { get; set; }

 

All the best,
Dimiter Madjarov
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
John
Top achievements
Rank 1
answered on 19 Mar 2013, 03:58 PM
Thank you for the reply.

What is the connection between data annotations and the field required popups that I see on the inline editing example at http://demos.kendoui.com/web/grid/editing-inline.html ?

That is the functionality that I would like to replicate. 

Thank you. 
0
Dimiter Madjarov
Telerik team
answered on 19 Mar 2013, 04:38 PM
Hi John,


The Grid is translating unobtrusive attributes to Kendo validator rules. To achieve this in an MVC Grid, you should use the approach from my previous post. To achieve it in a Web Grid, you should specify it in the model.
E.g.
schema: {
    model: {
        id: "ProductID",
        fields: {
            ProductID: { editable: false, nullable: true },
            ProductName: { validation: { required: true } },
            UnitPrice: { type: "number", validation: { required: true, min: 1} },
        }
    }
}

 

Kind regards,
Dimiter Madjarov
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
John
Top achievements
Rank 1
answered on 19 Mar 2013, 05:11 PM
I did use the approach (for the MVC grid) in your previous post. 

It sort of works in the sense that ModelState.IsValid is false when the call to my controller is made.

However, I am still trying to figure out what makes the client side validation bubbles appear in your example that I referenced.  Can you please help me with that? 

Thanks!
0
John
Top achievements
Rank 1
answered on 20 Mar 2013, 12:03 PM
Dimiter:

Thank you again for your help.

To recap what's happening now, if I edit a row in my kendogrid and click in/out of a required cell, the tooltip validator displays.  However, if I press the "update" button on the row, the validators do not run and the row is submitted.  

Basically, I'm trying to figure out how to make the validators display AND cancel the update/save (leaving the row I am editing expanded). 

Any thoughts?

0
Dimiter Madjarov
Telerik team
answered on 21 Mar 2013, 08:57 AM
Hello John,


Basically what you are trying to achieve is the expected behavior when using validation attributes. I am not aware of the current implementation of the Grid, so I prepared a sample project for you, demonstrating how to achieve this. Please take a look at it and let me know if it covers the current scenario.

Wish you a great day!

 

Regards,
Dimiter Madjarov
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
John
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
John
Top achievements
Rank 1
Share this question
or