Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

WebGrid provides an OnRowValidate client side events.

In this topic, you will learn the basic thing on how to validate empty cell when adding new row using OnRowValidate.

Panel

On this page:

Table of Contents
maxLevel3
stylecircle

To validate empty cell when adding new row using OnRowValidate

  1. Select WebGrid's instance and press F4.
  2. In Layout Settings, select ClientSideEvents, then set OnRowValidate to WebGrid1_OnRowValidate.
  3. Write the following function in OnRowValidate client side event:

    Code Block
    titleJavaScript
    languagejs
    function WebGrid1_OnRowValidate(rowObject)
    {
      var cellName = wgGetCellByName(rowObject, "ContactName");
      if (cellName.cellValue == "" || typeof(cellName.cellValue) == "undefined") 
      {
        alert("You must fill in ContactName.");
            // set focus the cellProduct and activate edit mode.
            ISGetObject("WebGrid1").ActivateEditMode();
            // return false so that the addnew will not process.
            return false;
      }
      return true;
    }
    
  4. Run the project.


Related Topics

Content by Label
spaces@self
reversetrue
showLabelsfalse
max5
sortmodified
labelswebgrid-kb-how-to-article -validate-that-a-selected-column-cannot-be-empty-when-adding-a-new-row-using-onrowvalidate
showSpacefalse
typepage