[CLOSED] DataAnnotations validation not working for gridpanel

  1. #1

    [CLOSED] DataAnnotations validation not working for gridpanel

    Hi,

    When there is any property decorated with DataAnnotations any attribute (for example Required) of data source of gridpanel.
    Then validation is not displayed, while this works for property which in not inside gridpanel but direct on form panel.

    Please let me know what i need to do to get this working.

    Thanks
    Last edited by Daniil; Jan 07, 2014 at 1:44 PM. Reason: [CLOSED]
  2. #2
    Hello!

    You mean CellEditing? I don't quite understand your requirements. Can you provide a sample?
  3. #3
    Attached Thumbnails Click image for larger version. 

Name:	gridpanel_form_post.jpg 
Views:	8 
Size:	31.3 KB 
ID:	7385  
  4. #4
    Sorry, it's still not clear.

    When you use TextFieldFor it should apply validation from the Model but when you use TextField or ComboBox it cannot know anything about the attributes in your Model. So you need to set them AllowBlank to false manually.

    If you want to bind list values using MVC DefaultModel binder you should follow special naming syntax. Please, read the following: http://haacked.com/archive/2008/10/2...o-a-list.aspx/

    If it's still not clear please provide a full sample to reproduce.
  5. #5
    Quote Originally Posted by Baidaly View Post
    Sorry, it's still not clear.

    When you use TextFieldFor it should apply validation from the Model but when you use TextField or ComboBox it cannot know anything about the attributes in your Model. So you need to set them AllowBlank to false manually.

    If you want to bind list values using MVC DefaultModel binder you should follow special naming syntax. Please, read the following: http://haacked.com/archive/2008/10/2...o-a-list.aspx/

    If it's still not clear please provide a full sample to reproduce.

    I am clear what you are trying to say, according to your approach if i follow special naming syntax to get my validation work.
    Then question would be is that possible in given scenario please see my View code and code to follow special naming syntax in given example(http://haacked.com/archive/2008/10/2...o-a-list.aspx/).

    <%@ Page Inherits="ViewPage<IList<Book>>" %>
    
    <% for (int i = 0; i < 3; i++) { %>
    
      <%: Html.TextBoxFor(m => m[i].Title) %>
      <%: Html.TextBoxFor(m => m[i].Author) %>
      <%: Html.TextBoxFor(m => m[i].DatePublished) %> 
    
    <% } %>
    for example -
     Html.X().ComponentColumn()
            .Editor(true)
            .DataIndex("DepartmentName")
            .Text("Department Name")
            .Component(Html.X().TextField().Name(Departments[0].DepartmentName))
    Please see [Departments[0].DepartmentName] in above code sample how can i achieve this in grid panel where my 'for' loop will give indexer value here it is '0'.

    Thanks
  6. #6
    Do you need an individual ComponentColumn for each Departments[0], Departments[1], Departments[2], etc.?

    Please provide us with the Model, some test data and explain how you need to show the data. Regardless from the Ext.NET context. Just an explanation (and mockups if needed).
  7. #7
    Attached Thumbnails Click image for larger version. 

Name:	DataAnnotation.png 
Views:	11 
Size:	11.6 KB 
ID:	7402  
  8. #8
    Thank you for clarifying.

    What about the following?

    @{
        Department depForEditor = new Department();
    }
    .Component(
        Html.X().TextFieldFor(m => depForEditor.DepartmentName).FieldLabel("") 
    )
    Or you can use a common TextField and its AllowBlank and BlankText properties.
    Last edited by Daniil; Dec 25, 2013 at 9:34 AM.

Similar Threads

  1. Replies: 9
    Last Post: Aug 05, 2013, 6:27 AM
  2. Remote Validation Not working.
    By fkmbkk in forum 2.x Help
    Replies: 3
    Last Post: Jun 28, 2013, 12:04 AM
  3. [CLOSED] Form Validation not working correctly
    By wisdomchuck in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Mar 04, 2013, 8:30 AM
  4. [CLOSED] Form validation is not working correctly
    By Fahd in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 13, 2012, 8:53 PM
  5. [CLOSED] textfield red underline validation not working
    By speedstepmem3 in forum 1.x Legacy Premium Help
    Replies: 13
    Last Post: Feb 16, 2012, 1:42 PM

Posting Permissions