When I am adding/editing a record I have a price field and I do not want to allow the user to input a negative number.
For employee price, the user should be able to leave the value blank but if they enter or select a value using the arrows they should not be able to enter/select anything less than 0.
Code:
@Html.EJS().Grid("InventoryGrid").DataSource(DataManager => { DataManager.Json(@Model.Inventory.ToArray()).InsertUrl("/Home/AddInventoryItem").UpdateUrl("/Home/UpdateInventoryItem").Adaptor("RemoteSaveAdaptor"); }).DataBound("dataBound").AllowFiltering(true).AllowMultiSorting(true).AllowSorting(true).AllowGrouping(true).AllowReordering().AllowResizing(true).AllowPdfExport().AllowExcelExport().ToolbarClick("toolbarClick").Width("auto").ShowColumnChooser(true).Columns(col =>
{
col.Field("Price").HeaderText("Price").EditType("numericedit").Format("C2").Edit(new { @params = new { decimals = 2, minValue=0 } }).ClipMode(Syncfusion.EJ2.Grids.ClipMode.EllipsisWithTooltip).Width("90").Add();
col.Field("EmployeePrice").HeaderText("Employee Price").EditType("numericedit").Edit(new { @params = new { decimals = 2, min = 0 } }).Format("C2").Width("160").Add();
col.Field("MemberPrice").HeaderText("Member Price").Visible(false).EditType("numericedit").Edit(new { @params = new { decimals = 2} }).Format("C2").ClipMode(Syncfusion.EJ2.Grids.ClipMode.EllipsisWithTooltip).Add();
}).AllowPaging(true).ActionBegin("actionBegin").ActionComplete("actionComplete").FilterSettings(filter => { filter.Columns(filterColumns).Type(Syncfusion.EJ2.Grids.FilterType.Excel); }).SortSettings(sort => sort.Columns(sortColumns)).PageSettings(page => page.PageCount(6).PageSizes(true)).EditSettings(edit => { edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true).Mode(Syncfusion.EJ2.Grids.EditMode.Dialog); }).Toolbar(new List<string>() { "Add", "Edit", "ExcelExport", "PdfExport", "Search", "ColumnChooser" }).ContextMenuItems(new List<object>() { "SortAscending", "SortDescending", "Edit","Save", "Cancel", "PdfExport", "ExcelExport","FirstPage", "PrevPage", "LastPage", "NextPage" }).Render()