View Full Version : Unique value in the fields of a column - validation problem

11 Aug 2009, 9:25 PM
I have a EditorGridPanel.

In this grid I have a column where the values have to be unique. It's like a ID column, but the user write the content.

I have to validate and block when the user write a value that another record already have.

For a better explain, imagine a column with numbers (int) . If a record have the value '1' on this column, any new record or editing records can have the same value. If the user type this value, I have to mark this field as invalid.

Another thing, I tried a validator do solve that but I didn't get a solution.
When the field is invalid, the value of the field disappear (when the record is a new one) or return to the old value (when I edit an existing record). How can I do to keep the new value on the field and mark it as invalid?


12 Aug 2009, 9:23 AM


12 Aug 2009, 6:39 PM
Please, I need help!


13 Aug 2009, 9:28 AM

13 Aug 2009, 10:41 AM
Please stop bumping your thread. It should be obvious by the lack of replies that you're not providing enough information for someone to respond.


13 Aug 2009, 10:56 AM

if I didn't give enough information I can give more. Just say what you want to help me.

If you don't say what you didn't understand to help me, I can't guess by myself.

I don't post without looking the examples, the API and searching on the forum. Like you can see, I have just few post with doubts, so I search a lot before asking someone.

I just want to know how can I make a column with unique values, like a ID column, but the user can edit the content. I don't think this is dificult to understand, but if I'm wrong, just say what can I explain better.

Another example for what I want to do.

Imagine a grid with a email column, like the example: http://extjs.com/deploy/dev/examples/writer/writer.html
In my case, the email column has to be unique. Nobody can insert a new record with the same email.
So, I want to get an invalid message and make the field invalid when the user type an email that already exist in the grid. I want to invalidate the field after the person edit the field. This have to be done when the user add a new record or when the user edit an existing record.

It's like the column is a primary key or unique field in the database.

I'm clear enough now?

And I stil want to know another thing.
How can I keep the value that the user typed when a field get invalid?
Imagine a field when the user can't type the word 'test'. When I type this word, the value of the field disappear or return to the old value, the value that was there before. How I can keep the value 'test' and make the field invalid?


14 Aug 2009, 6:52 AM

I tried to explain better. I don't know what more I can say to explain my problem.

If someone didn't understand, please say to me and I'll try to say in another way to someone help me.


John Sourcer
17 Aug 2009, 1:09 AM
Off the top of my head. Poss not very elegant.

validator: function(value){
var nomatch = true;
if (value === record.get('username')){
return false;

return nomatch;

17 Aug 2009, 4:23 AM
Thank you for the post.

I tried something like that before, but the problem is when the field is invalid by this validator, the value of the field disappear (when the record is a new one) or return to the old value (when I edit an existing record). How can I do to keep the new value on the field and mark it as invalid?


17 Aug 2009, 4:27 AM
Ext has no support for this by default (I once wrote a plugin to support marking cells invalid -- you'll have to search the forum).

17 Aug 2009, 4:37 AM
Thanks Condor, but is it possible to keep the value of the field, even the field get invalid?

If I add a new record and type, for example, the word 'test' and this is an invalid word, when the blur event of the field occur, the field get blank. Is is possible to keep the value 'test'?


17 Aug 2009, 4:43 AM
The trick is to not invalidate the value, but still store that it was invalid.

See this thread (https://extjs.com/forum/showthread.php?p=211373#post211373) (this was for a really old Ext version, I hope it still works with Ext 3.0).

17 Aug 2009, 4:46 AM
I was reading this thread.....

I'll try and post after the result.

Thanks Condor.