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

[Solved] Client side validation event needed

4 Answers 92 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.
Bob
Top achievements
Rank 1
Bob asked on 13 Jan 2012, 10:43 PM
I know I can tie into the standard MVC validations while editing a grid but I don't think that will work or is even needed here.

What I want to do is validate that a value entered into a column is unique in that grid. This grid will have a small number of rows that will always be in the client. Also, since they can add multiple rows at a time I can't use for example a remote validation and verify that the field is not in the db since it might not be even if they entered it in another row.

I tried to use the OnEdit event. But, that seems to fire when I click into the field to edit rather than after the user edits it.

I also tried to use jQuery delegate for the blur even of the input fields. But that never fires. I expect it is because the input tag is added/removed on the fly during batch editing. 

I really need some type of OnChanged event or something.

thanks,
BOb

4 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 16 Jan 2012, 09:46 AM
Hi Bob,

I suppose that the appropriate event which suits your case is the onSave client event of the Grid.
I hope this helps.

Regards,
Petur Subev
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
Bob
Top achievements
Rank 1
answered on 17 Jan 2012, 09:40 PM
How would I go about looping through the data to count the matching values. Basically I am trying this in the onSave:

        var count = 0;
        $("tr", e.currentTarget).each(function () {
            if ($(e.currentTarget).data("tGrid").dataItem($(this)).FiscalYear == e.values.FiscalYear)
                count++;
        });

but not having any luck. 

thanks for any advice.
BOb

0
Petur Subev
Telerik team
answered on 18 Jan 2012, 01:41 PM
Hello Bob,

I assume that the problem is the selector used to get the tr elements.
You should use $("tr", "#YourGridName tbody")because the one you used includes the row in the header which causes an exception.

All the best,
Petur Subev
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
Bob
Top achievements
Rank 1
answered on 18 Jan 2012, 06:11 PM
Thanks. I'll give it a try.

BOb
Tags
Grid
Asked by
Bob
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Bob
Top achievements
Rank 1
Share this question
or