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
- Create DeleteRow function to delete the selected row in WebGrid.
JavaScript Copy 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."); } }
- Create ValidateRow function to validate the selected row in WebGrid.
JavaScript Copy 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."); } }
- Run the project.
Other Resources
Walkthrough Topics
How-to Topics