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

Validation input data lost

2 Answers 128 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
zhivko.zhelezov
Top achievements
Rank 1
zhivko.zhelezov asked on 15 Jun 2016, 03:17 PM

Hello, 

I have a datasource in which i have initialized a validation as this:

  minvaluevalidation: function (input) {

                                        if (input.is("[name='minValue']")) {
                                            if ((parseFloat($("input[type='text'][name='minValue']").val()) > parseFloat($("input[type='text'][name='maxValue']").val()))) {
                                                input.attr("data-minvaluevalidation-msg", "Min Value should be less than Max Value");
                                                return false;
                                            }
                                        }

                                        return true;
                                    }
                                }

(also relative to maxvaluevalidation field)

 

I have a grid to which this datasource is bound. The user can insert rows in this grid and everything works fine.

Let's suppose I have typed for minValue the number 6 and then for maxValue the number 5.

Then the minvaluevalidation function says 'false' there is a validation problem. Ok, I try to type 7 for the maxValue(bigger than 6) and click the 'update' button of the edit form of kendo. Here I know that this is valid and also the maxvaluevavlidation function returns true. But the 'update' or 'create' transport (CRUD operation) function has wrong data, there is no pair [6;7] there is pair [0;7] (or instead 0, the last valid typed number in grid) and the grid is updated with values 0 and 7....not with 6 and 7

 

So when validation is broken for minValue, if I fix this for maxValue(not for minValue) and suddenly click 'update' while the validation message is still visible for minValue the data passed to the transport functions is wrong.

Here If I try to change minValue to 3 and then again to 6 everything is updated and the transport function has right data, the grid has right data.

Thanks!

 

 

 

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 17 Jun 2016, 03:51 PM
Hello Zhivko,

When the validation for the minValue field fails the current value is not saved, that is why it is returning 0 or the last valid value.

I can suggest the following:

1) Wire the save event of the grid

2) Get the latest values of the 'minValue' and 'maxValue' editors

3) Update the model accordingly
save: function(e) {
  var minValue= e.container.find("[name=minValue]").data().kendoNumericTextBox.value();
  var maxValue= e.container.find("[name=maxValue]").data().kendoNumericTextBox.value();
               
  e.model.set("minValue", minValue);
  e.model.set("maxValue", maxValue);
}

Let me know if you need additional assistance.

Regards,
Stefan
Telerik
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
0
zhivko.zhelezov
Top achievements
Rank 1
answered on 18 Jun 2016, 11:48 AM

Hello Stefan,

thank you this works for me now fine

 

Regards

Tags
Data Source
Asked by
zhivko.zhelezov
Top achievements
Rank 1
Answers by
Stefan
Telerik team
zhivko.zhelezov
Top achievements
Rank 1
Share this question
or