Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
615
Best way to validate for unique values in a column of the grid?
posted

Hello,

I'm working with an MVC5 project, and I'm trying to figure out the best way to approach this problem.  In my grid, there is a column for "Name" which displays a particular name that has meaning in my business logic.  This column is not the primary key of the grid.  However, the rule is that "Name" must be unique for all items in the collection, so if the user edits a row in the grid and changes the Name to one that is already in use, I need to prevent that.

Looking through the iggrid documentation, I wasn't sure if there is a validation option in the MVC helper that I could use, or if it would be better for me to do something with the editRowEnding event, perhaps, and check the new Name against all of the other names in the grid.  Ideally, I'd like to provide a little validation message on the cell (like what I see when I mark a cell as required and don't input a value), and of course I need to stop the row from being updated.

I'm mainly posting because I didn't want to lose a lot of time chasing an approach that doesn't make good use of the API, and since this has probably been done before, I wanted to see if others had any opinions about how to approach this.

Thanks!