简体   繁体   中英

Minimum Maximum Validation in telerik mvc Grid

I have one grid that have two fields called minimum and maximum.

@(Html.Kendo().Grid<FS.ERP.CMVC.Models.LeavePolicyDetailViewModel>()
 .Name("gridExample")
 .Columns(columns =>
 {

  columns.Bound(p => p.Minimum).Width(100).HtmlAttributes(new { id = "minimum"});
  columns.Bound(p => p.Maximum).Width(100).HtmlAttributes(new { id = "maximum"});                                                                                                                         
  })
 .ToolBar(toolBar =>
  {
     toolBar.Create();
  })
 .Editable(editable => editable.Mode(GridEditMode.InCell))
 .Pageable()
 .Sortable()
 .Scrollable()
 .HtmlAttributes(new { style = "height:550px;" })
 .DataSource(dataSource => dataSource.Ajax()
                                     .Batch(true)
                                     .ServerOperation(false)                                                    
                                     .PageSize(20)                                                
                                            )                                         
                                            ) 

I want my values to writen in the minimum maximum range. If the user writes value in minimum cell first then Maximum must be greater than it and If user writes in maximum first then minimum should always b less then maximum.

Any help would be appreciated!

On save command in kendo grid, you can achieve this functionality. Attach save event in your kendo grid like this,

save : function (e) {
    //access both min and max value
    alert(e.values.maximum);
    alert(e.values.minimum)

    //your logic- do whater you want
    e.model.set("minimum", some value);
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM