This is a migrated thread and some comments may be shown as answers.

Add new/error handling with incell editing

3 Answers 360 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 12 May 2015, 06:48 PM

I have a grid which is set to editable:true, batch: false, and then I have and "add new" button via the toolbar: ["create"] directive.  When a user clicks on that it instantly pings the backend server.  The row requires a number of fields to be filled in before it is considered and valid.  So right now until all the fields are valid, I return an error.  

 The problem is conveying that the user must enter all required fields before it is saved on the backend.  How can I get within the error: function(e){...} the most recent row that it is trying to sync?  I'd ideally want to continue to highlight whatever fields are missing as "required" until they fill them all in.  I'd also want it to leave the icon in the top left of the box on the ones showing they are not yet saved.  

 

I could return then something like:

 

{
  "errors": {
    "name": [
      "REquired"
    ],
    "description": [
      "required",
      "must be more than 5 characters"
    ]
  }
}

Then I'd loop through the errors and match up the fields that have errors and show some sort of indication to the end user.  

 

Let me know what was is best to accomplish that or if there is a better way I should be doing this.

Thanks,

Matt

3 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 14 May 2015, 10:56 AM

Hello Matt,

An easy way to implement validation functionality would be setting the validation in the data source schema.model. Please refer to the example code in the article that shows how to set required field validation for the ProductName field. 

Hope that this will be helpful. 

 

Regards,
Boyan Dimitrov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Matt
Top achievements
Rank 1
answered on 14 May 2015, 12:02 PM
Thanks is there a way to validate over an entire row?  Right now I already have my validation set to required for all the fields, but when the user first clicks "Add new row" they aren't prompted to enter data to each field and there is no indication that they are all required to the end user until they click on each cell to cause the validation to fire.
0
Boyan Dimitrov
Telerik team
answered on 18 May 2015, 08:05 AM

Hello Matt,

A possible solution is to get the kendoValidator widget for the edited cell in the edit event and call the validate method. Please refer to the http://dojo.telerik.com/EfeRI/2 for an example. 

Regards,
Boyan Dimitrov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Matt
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Matt
Top achievements
Rank 1
Share this question
or