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

[Solved] Inline Editing client validation not showing if command column is on the right

3 Answers 68 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Andrew
Top achievements
Rank 1
Andrew asked on 13 Mar 2012, 02:45 AM
i have a model with 2 properties for example ProductName and MyName, lets say ProductName  is my primary key so i set it as my DataKey in the telerik grid all works fine aslong as i position the column commands after all the other columns. The problem is when i position the column commands at the far left side just before the other columns which makes some of the client validation is not displaying. 

example: using this code will place the column commands right before the ProductName when i try to trigger any client validation ProductName client side validation will not display but MyName column's client side validation will.
@(Html.Telerik().Grid<EditableProduct>()
        .Name("Grid")
        .DataKeys(keys =>
        {
            keys.Add(p => p.ProductName 
);
        })
        .ToolBar(commands => commands.Insert().ButtonType(GridButtonType.Image).ImageHtmlAttributes(new {style="margin-left:0"}))
        .DataBinding(dataBinding =>
        {
            dataBinding.Ajax()
                .Select("_SelectAjaxEditing", "Home")
                .Insert("_InsertAjaxEditing", "Home")
                .Update("_SaveAjaxEditing", "Home")
                .Delete("_DeleteAjaxEditing", "Home");
        })
        .Columns(columns =>
        {
             
            columns.Command(commands =>
            {
                commands.Edit().ButtonType(GridButtonType.Image);
                commands.Delete().ButtonType(GridButtonType.Image);
            }).Width(180).Title("Commands");
 
            columns.Bound(p => p.ProductName).Width(210);
            columns.Bound(p => p.MyName).Width(210);
        })
        .Editable(editing => editing.Mode(GridEditMode.InLine))
        .Pageable()
        .Scrollable()
        .Sortable()       
)


i have also found out that if i use a different column as DataKey all will work fine where ever i place the command columns, but i am trying to avoid adding a new column for the DataKey. Is there any fix for this? 



3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 16 Mar 2012, 06:17 PM
Hello Andrew,

I reproduced the problem you wrote about. It is caused because a hidden input needs to be created for the datakey when generating the edit command and in MVC the validation attributes aren't set when requested for a second time. I am afraid that this cannot be fixed as it will break existing functionality. Please accept our apologies for the caused inconvenience.

Greetings,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
0
Chris
Top achievements
Rank 1
answered on 15 May 2012, 05:52 PM
Hi,

I believe I have may have a similar problem but am seeking confirmation:

I have an MVC Telerik grid with the following in the declaration in the Index Razor file for the Model's view:

.Editable(e => e.Mode(GridEditMode.InForm))

And then a separate Razor file in Shared/EditorTemplates for the same Model.

The model has two string attributes and one that is using an enum and all have the [Required] attribute.  The editor template Razor file binds these using two EditorFor statements for the two strings and then a Telerik Combobox for the enum one.

When I use the insert function on the grid and don't enter anything in the text fields or select anything from the combobox, the client side validation isn't being done - it's hitting the controller insert function.  I've checked that the client side validation js includes are there and they are and that the web.config settings are correct.  Client side validation on other Razor pages happens absolutely fine.

Is this the same problem that you say there is no solution to?   If so, can you recommend a workaround?

Cheers

Chris
0
Daniel
Telerik team
answered on 18 May 2012, 12:37 PM
Hi Chris,

This doesn't seem to be the same problem. Could you provide more information about the editor template and the model? I also suggest to check the Common Validation Problems code-library which lists some of the common problems with the validation.

Greetings,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
Tags
Grid
Asked by
Andrew
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Chris
Top achievements
Rank 1
Share this question
or