Validation in Editable GridPanel

  1. #1

    Validation in Editable GridPanel


    Hi Guys,

    I have a Editable GridPanel. All the Editor fields in the grid have been marked as AllowBlank="false". Now Before firing
    <Click Handler="#{grid}.save();" />
    I would like to validate the entries.

    Can some one suggent me the best way to do it.

    Thanks in advance.
  2. #2

    RE: Validation in Editable GridPanel

    Hi,

    You need use ValidateEdit event of GridPanel


    validateedit : ( Object e )
    Fires after a cell is edited, but before the value is set in the record. Return false to cancel the change. The edit event object has the following properties
    grid - This grid
    record - The record being edited
    field - The field name being edited
    value - The value being set
    originalValue - The original value for the field, before the edit.
    row - The grid row index
    column - The grid column index
    cancel - Set this to true to cancel the edit or return false from your handler.
    Listeners will be called with the following arguments:
    e : Object
    An edit event (see above for description)
  3. #3

    RE: Validation in Editable GridPanel

    I am looking for some thing equivalent to form's valid() method ? Is there any such method exists ?
  4. #4
    Hi,

    I have given Validation attributes and VType on the Editor Control(e.g TextField) for a column in the GridPanel.
    Is there any way through which i can validate the Editor value against the Validation attributes set in the EditorControl
    I want to do this on the ValidateEdit event of the GridPanel.

    So basically whenever user enters any value the ValidateEvent will be called and i will check the value entered in that cell with the Validation attribute specified for the Editor of that Column.

    Please throw some light on this.

    Regards,
    Huzefa
  5. #5
    Hi,

    I have been able to get this working by using this code on ValidateEdit event
    var column = e.grid.colModel.getColumnById(e.field);
     if(column!=null){
         var valid = column.editor.field.isValid(false);
         if(!valid){
             e.cancel = true;
         }
     }
    Now the triangle red color dirty mark is coming for column which fails validation.

    But the problem now is that how can i restrict the Form to be submitted unless the user doesn't fulfill the column validations.

    Even when the GridColumn is in invalid state, the Form can be submitted.
    Please suggest me how can i do it without knowing the GridPanel in the Form.


    Regards,
    Huzefa

Similar Threads

  1. Replies: 4
    Last Post: Dec 09, 2011, 12:15 PM
  2. Replies: 3
    Last Post: Jul 11, 2011, 9:43 AM
  3. editable grid and custom validation with regular expression
    By n_s_adhikari@rediffmail.com in forum 1.x Help
    Replies: 0
    Last Post: Sep 24, 2009, 5:08 PM
  4. [CLOSED] Editable GridPanel Validation
    By bethc in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Sep 22, 2009, 6:46 AM
  5. Editable Grid validation
    By n_s_adhikari@rediffmail.com in forum 1.x Help
    Replies: 0
    Last Post: Aug 06, 2009, 6:20 PM

Posting Permissions