Intersoft WebGrid Documentation
How-to: Extend data editing with Client-Side APIs
See Also Send comments on this topic.

Glossary Item Box

Besides adding and editing data, WebGrid is also applicable for deleting and validating row.

In this topic, you will learn how to implement deleting and validating using Client-Side API.

To extend data editing with Client-Side APIs

  1. Create DeleteRow function to delete the selected row in WebGrid.
    JavaScript Copy ImageCopy Code
    function DeleteRow()
    {
       // retrieves WebGrid's object
       var grid = ISGetObject("WebGrid1");
                
       var selectedObject = grid.GetSelectedObject();  // return object of type SelectedObject                       
       if (selectedObject != null)
       {   
          var selectedRow = selectedObject.ToRowObject(); // return WebGridRow object
          selectedRow.Delete(); // delete the selected row 
       }
       else
       {
          alert("Please select a row first.");
       }
    }
    

  2. Create ValidateRow function to validate the selected row in WebGrid.
    JavaScript Copy ImageCopy Code
    function ValidateRow()
    {
       // retrieves WebGrid's object
       var grid = ISGetObject("WebGrid1");
                
       var selectedObject = grid.GetSelectedObject();  // return object of type SelectedObject                               
       if (selectedObject != null)
       {
          var selectedRow = selectedObject.ToRowObject(); // return WebGridRow object
          selectedRow.Validate(); // validate the selected row
       }
       else
       {
          alert("Please select a row first.");
       }
    }
    

  3. Run the project.

See Also

©2012 Intersoft Solutions Corp. All Rights Reserved.