The official release of Ext.NET Mobile is now available. Ext.NET Mobile is an ASP.NET component framework for building Phone and Tablet specific mobile web applications. Read More

RowEditor startEdit and validation

Page 1 of 2 12 LastLast
  1. #1

    RowEditor startEdit and validation

    I am using a RowEditor in a fairly standard scenario with most of the code taken from the demos. I have an add button that I've wired up in what seems to be a fairly standard way:

    var grid = #{GridPanel1};
    grid.insertRecord(0, {
    name   : ""
    I have some validation attached to the 'name' textfield. The validation prevents a range of inputs including the empty string. That all works fine. If the user edits a row, they have to cancel or fix any validation errors before they can commit the row or select another row. No problems here.

    The validation is a custom validation function configured like so:

    <ext:TextField ... Validator="myValidationFunction" ... />
    However, I've run into the following scenario:

    When I add a row, I can't really provide a valid default for the 'name' field. I default the field value to an empty string as per the example above.

    The user clicks the add button, they get the new row and RowEditor appearing, and the roweditor even shows the correct validation error (empty strings are not allowed). This is fine.

    The problem is that the user is then able to select another row and is NOT prevented from doing this even though the input is invalid. The result is a new row with invalid data.

    I'm guessing this is because I'm doing an 'add' and then an 'edit' and the grid/roweditor doesn't force the user to supply a valid input if they did not change the original field value (even if the original field value was invalid).

    If I'm not missing anything obvious, is there any reasonable workaround for this? I've tried solving this with the RowEditor Before/After edit events or by looking at ways to change the field value to trick the RowEditor into thinking the value has been changed. No luck so far.
  2. #2

    Please use ValidateEdit.
  3. #3
    The ValidateEdit event does not fire in the scenario I described. This was one of the first things I tried. I also couldn't find any other events that would let me do something similar.
  4. #4
    Could you provide a sample to test with?
  5. #5
    I can provide a project sample but I think the problem can be demonstrated in the gridpanel/plugins/roweditor demo. In the demo, how would you prevent the user from adding a row with "New Guy" as the name? (meaning, if you needed to keep the default as New Guy, how could you ensure that the user changes it to a real name when they add a new row?)
  6. #6
    You could try to handle the Change event of a TextField.
  7. #7
    Though I'd suggest you to set up custom validation for an Editor.

        Header="First Name" 
        DataIndex="name" >
                Validator="function (v) { 
                                if (v === 'New Guy') {
                                    return 'Enter name';
                            }" />
  8. #8
    I tried the editor control validation approach but unfortunately this don't address the problem.

    The problem, as I see it, is that the row editor doesn't lock the user to the row if the user hasn't made any changes to the data in the row, even if that data doesn't pass validation. I think this behaviour is fine, but it doesn't work very well with the add-to-store-and-start-edit approach for adding a new row.

    I have worked around the problem but in a less than ideal way. It would be nice to find a solution to what, in my mind, is a fairly standard scenario.
  9. #9
    Quote Originally Posted by ralex View Post
    I tried the editor control validation approach but unfortunately this don't address the problem.
    Please clarify why.
  10. #10
    A user can still move to another row after doing an add. The validation does not stop that. You can easily test this by adding the bit of validation to the RowEditor demo and see that this is the case.
Page 1 of 2 12 LastLast

Similar Threads

  1. Remote Validation using RowEditor
    By mait_k in forum 1.x Help
    Replies: 1
    Last Post: Dec 20, 2011, 5:24 PM
  2. RowEditor validation
    By reezvi in forum 1.x Help
    Replies: 0
    Last Post: Aug 12, 2011, 7:36 PM
  3. [CLOSED] RowEditor & Form Validation
    By ljcorreia in forum 1.x Premium Help
    Replies: 4
    Last Post: Jul 22, 2011, 10:45 AM
  4. [CLOSED] RowEditor Validation
    By ljcorreia in forum 1.x Premium Help
    Replies: 1
    Last Post: Jul 20, 2011, 1:21 PM
  5. Replies: 2
    Last Post: Feb 09, 2010, 9:04 AM

Tags for this Thread

Posting Permissions