prevent the auto-correction from happening

1 posts, 0 answers
  1. Sushma
    Sushma avatar
    1 posts
    Member since:
    Jul 2013

    Posted 07 Aug 2013 Link to this post

    Hi!

    If I enter a value in the Perday Price or Total Price fields with a decimal .00, it removes the .00, but if we go back (before clicking save) and add the 1.00 back, it takes it.

    I was thinking that if we can set “validateOnBlur” to false then it might prevent the auto-correction from happening as well.  The problem is that I can’t figure out how to do this.

     http://docs.kendoui.com/api/framework/validator#configuration-validateOnBlur

    <fieldset>
          <legend>Topline Price Information</legend>
    @(Html.Kendo().Grid<Presentation.Web.Models.TopLinePrice>()
               .Name("Grid")
               .Columns(columns =>
                          {
                            columns.Bound(m => m.ProjectNumber)
                              .Title(ScanDataResources.ProjectNumber)
                              .Width(120);
                            columns.Bound(m => m.ClientName)
                              .Title(ScanDataResources.ClientIdName);
                            columns.Bound(m => m.PerDayPrice)
                              .Title(ScanDataResources.PerDayPriceName)
                              .Format("{0:c2}")
                              .Width(100);
                            columns.Bound(m => m.TotalPrice)
                              .Title(ScanDataResources.TotalPriceName)
                              .Format("{0:c2}")
                              .Width(100);
                            columns.Bound(m => m.IsPriceOverridableDescription)
                              .Title(ScanDataResources.Overriden)
                              .Visible((int)@ViewBag.SystemId == (int)CoreConstants.PWSystem.RAMS)
                              .Width(75);
                            columns.Bound(m => m.LastSentDate)
                              .Title(ScanDataResources.ModifiedDate)
                              .Width(180);
                            columns.Bound(m => m.ModifiedByPersonName)
                              .Title(ScanDataResources.ModifiedByName)
                              .Width(120);
                            columns.Command(commands => commands.Edit()
                              .Text(@Buttons.Edit).HtmlAttributes(new { @Style = "text-align:center; " })
                              .CancelText(@Buttons.Cancel)
                              .UpdateText(@Buttons.Save)
                              ).Title("")
                              .Width(160);
                          })
               .Events(e => e.Save("OnSave"))
               .Events(e => e.Edit("OnEdit"))
               .Editable(editable => editable.Mode(GridEditMode.InLine)) // Use inline editing mode
               .DataSource(dataSource =>
               dataSource.Ajax()
                .Model(model =>
                {
                  model.Id(p => p.ProjectPriceId); // Specify the property which is the unique identifier of the model
                  model.Field(p => p.ProjectNumber).Editable(false); // Make the ProjectNumber property not editable
                  model.Field(p => p.LastSentDate).Editable(false);
                })
                .Read(read => read
                  .Action("GetScanDataTopLinePrice", "ScanDataTopLinePrice")
                .Data("ScanData.GetSearchModel"))  // Action invoked when the grid needs data
                .Update(update => update
                  .Action("UpdatePrice", "ScanDataTopLinePrice"))  // Action invoked when the user saves an updated data item
                .Events(events => events.RequestEnd("OnRequestEnd_TopLinePriceGrid"))
                .PageSize(10)
    
              )
            
            )
     </fieldset>
     <script type="text/javascript">
     function OnEdit(e) {
         $('#PerDayPrice').change(function () {
           var perDayPrice = $(this).val();
           var isDecimalFound = perDayPrice % 1 != 0;
           if (!isDecimalFound) {
             $(this).val(perDayPrice + '.00');
           }
         });
         $('#TotalPrice').change(function () {
           var totalPrice = $(this).val();
           var isDecimalFound = totalPrice % 1 != 0;
           if (!isDecimalFound) {
             $(this).val(totalPrice + '.00');
           }
         });
         // Clear validation errors.
         e.container.find('.k-grid-cancel').bind('click', function() {
           Validation.ClearValidationErrors('MainValidationSummary');
         });
    
       }
    </script>

    Thanks

Back to Top